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: about 1 month 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 (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-12-28T09:04:10.000Z (11 months ago)
- Last Synced: 2024-09-30T23:42:13.254Z (about 2 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
[![npm version](https://badge.fury.io/js/%40technote-space%2Fgithub-action-test-helper.svg)](https://badge.fury.io/js/%40technote-space%2Fgithub-action-test-helper)
[![CI Status](https://github.com/technote-space/github-action-test-helper/workflows/CI/badge.svg)](https://github.com/technote-space/github-action-test-helper/actions)
[![codecov](https://codecov.io/gh/technote-space/github-action-test-helper/branch/master/graph/badge.svg)](https://codecov.io/gh/technote-space/github-action-test-helper)
[![CodeFactor](https://www.codefactor.io/repository/github/technote-space/github-action-test-helper/badge)](https://www.codefactor.io/repository/github/technote-space/github-action-test-helper)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](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)