Skip to content

Commit

Permalink
テストの追加 (#30)
Browse files Browse the repository at this point in the history
* testディレクトリをincludeする
tsconfigのincludeはrolllupには影響しないことを確認済みです

* mswをインストール

* .prettierrcでダブルクォーテーションが抜けているのを修正

* jest関連をインストール

* テストファイル用のeslint設定を追加

* mswののセットアップ

* テスト環境のセットアップを修正

* coverageディレクトリをgitignoreに追加

* coverageを測定できるように調整

* isCheckValueファイルのテストを追加

* parseQueryファイルのテストを追加

* createClientについてのテストを追加

* getメソッドに関してのテストを追加

* releaseのGitHubActionsにテストスクリプトを追加

* typescriptのeslint設定の優先度を上げる
型定義のところにもun-defルールとかが適用されてしまうのを修正

* 不要なコメントを削除
  • Loading branch information
dc7290 authored Aug 3, 2022
1 parent d9c1521 commit 7c00816
Show file tree
Hide file tree
Showing 17 changed files with 6,747 additions and 1,262 deletions.
8 changes: 7 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
parser: '@typescript-eslint/parser',
extends: ['plugin:@typescript-eslint/recommended', 'eslint:recommended'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
Expand All @@ -21,4 +21,10 @@ module.exports = {
es6: true,
jest: true,
},
overrides: [
{
files: ['tests/**'],
plugins: ['jest'],
},
],
};
27 changes: 14 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- name: release on npm
run: |
npm ci
npm run lint
npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
registry-url: 'https://registry.npmjs.org'
- name: release on npm
run: |
npm ci
npm run lint
npm run test
npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
coverage
4 changes: 2 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
semi: true,
singleQuote: true
"semi": true,
"singleQuote": true
}
8 changes: 8 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
setupFilesAfterEnv: ['./jest.setup.ts'],
collectCoverageFrom: ['src/**/*.ts', '!src/index.ts', '!src/types.ts'],
coverageProvider: 'v8',
};
9 changes: 9 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { server } from './tests/mocks/server';

// Establish API mocking before all tests.
beforeAll(() => server.listen());
// Reset any request handlers that we may add during the tests,
// so they don't affect other tests.
afterEach(() => server.resetHandlers());
// Clean up after the tests are finished.
afterAll(() => server.close());
Loading

0 comments on commit 7c00816

Please sign in to comment.