@technote-space/github-action-test-helper
v0.11.17
Published
Test helper for GitHub Actions.
Downloads
149
Readme
GitHub Actions Test Helper
GitHub Actions 用テストヘルパー
Read this in other languages: English, 日本語.
Table of Contents
使用方法
- インストール
npm i @technote-space/github-action-test-helper
- 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/]
},
},
});
- 使用
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();