Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/technote-space/github-action-test-helper
Test helper for GitHub Actions.
https://github.com/technote-space/github-action-test-helper
github-actions
Last synced: 4 months ago
JSON representation
Test helper for GitHub Actions.
- Host: GitHub
- URL: https://github.com/technote-space/github-action-test-helper
- Owner: technote-space
- License: mit
- Created: 2019-09-22T05:20:35.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-12-28T09:04:10.000Z (about 1 year ago)
- Last Synced: 2024-09-30T23:42:13.254Z (5 months ago)
- Topics: github-actions
- Language: TypeScript
- Homepage:
- Size: 2.8 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.ja.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# GitHub Actions Test Helper
[](https://badge.fury.io/js/%40technote-space%2Fgithub-action-test-helper)
[](https://github.com/technote-space/github-action-test-helper/actions)
[](https://codecov.io/gh/technote-space/github-action-test-helper)
[](https://www.codefactor.io/repository/github/technote-space/github-action-test-helper)
[](https://github.com/technote-space/github-action-test-helper/blob/master/LICENSE)GitHub Actions 用テストヘルパー
*Read this in other languages: [English](README.md), [日本語](README.ja.md).*
## Table of Contents
Details
- [使用方法](#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95)
- [Author](#author)## 使用方法
1. インストール
`npm i @technote-space/github-action-test-helper`
2. Vitest の設定
```js
///
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/]
},
},
});
```
3. 使用
```js
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)](https://github.com/technote-space)
[Blog](https://technote.space)