@technote-space/github-action-test-helper

Test helper for GitHub Actions.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@technote-space/github-action-test-helper
0.9.102 months ago3 years agoMinified + gzip package size for @technote-space/github-action-test-helper in KB

Readme

GitHub Actions Test Helper
npm version CI Status codecov CodeFactor License: MIT
GitHub Actions 用テストヘルパー
Read this in other languages: English, 日本語.

Table of Contents

Details

使用方法

  1. インストール
npm i @technote-space/github-action-test-helper
  1. Vitest の設定
/// <reference types="vitest" />
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
  test: {
    setupFiles: './src/setup.ts',
    clearMocks: true,
    mockReset: true,
    restoreMocks: true,
    coverage: {
      reporter: ['html', 'lcov'],
    },
    deps: {
      // 以下の設定が必要
      inline: [/github-action-test-helper/]
    },
  },
});
  1. 使用
import {
	getContext,
	generateContext,
	encodeContent,
	getConfigFixture,
	getApiFixture,
	disableNetConnect,
	testEnv,
	testChildProcess,
	setChildProcessParams,
	testFs,
	spyOnStdout,
	stdoutCalledWith,
	stdoutContains,
	stdoutNotContains,
	spyOnExec,
	execCalledWith,
	execContains,
	execNotContains,
	testProperties,
	setupGlobal,
	getOctokit,
} from '@technote-space/github-action-test-helper';
import nock from 'nock';

getContext({});
generateContext({});
encodeContent('content');
getConfigFixture('rootDir', 'fileName');
getApiFixture('rootDir', 'name');
disableNetConnect(nock);
testEnv();
testChildProcess();
setChildProcessParams({stdout: 'test-stdout', stderr: 'test-stderr', error: new Error('test-error')});
testFs();
const stdoutSpy = spyOnStdout();
stdoutCalledWith(stdoutSpy, []);
stdoutContains(stdoutSpy, []);
stdoutNotContains(stdoutSpy, []);
const execSpy = spyOnExec();
execCalledWith(execSpy, []);
execContains(execSpy, []);
execNotContains(execSpy, []);
testProperties({}, {});
setupGlobal();
getOctokit();

Author

GitHub (Technote)

Blog