Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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)