Skip to content

Commit

Permalink
chore: add test coveragge
Browse files Browse the repository at this point in the history
  • Loading branch information
tianyingchun committed Aug 7, 2024
1 parent 455e884 commit 5c54840
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- main

jobs:
coverage-badge:
test-coverage:
strategy:
matrix:
os:
Expand All @@ -17,6 +17,13 @@ jobs:
pnpm:
- 7
runs-on: ${{ matrix.os }}

permissions:
# Required to checkout the code
contents: read
# Required to put a comment into the pull-request
pull-requests: write

steps:
- name: checkout repository
uses: actions/checkout@v4
Expand All @@ -28,17 +35,10 @@ jobs:
- name: 📥 Install Dependencies
run: yarn --frozen-lockfile

- name: run coverage
run: yarn test:coverage
- name: 'Run test coverage'
run: npx vitest --coverage.enabled true

- name: generate badges
run: yarn generate-badges

- name: push coverage artifacts to another branch
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./coverage
publish_branch: coverage
allow_empty_commit: true
- name: 'Report Coverage'
# Set if: always() to also generate the report if tests are failing
# Only works if you set `reportOnFailure: true` in your vite config as specified above
uses: davelosert/vitest-coverage-report-action@v2
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"request": "launch",
"name": "Debug Test File",
"runtimeExecutable": "npm",
"runtimeArgs": ["run-script", "test-unit"],
"runtimeArgs": ["run-script", "test"],
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"args": ["${relativeFile}"],
"env": {}
Expand Down
9 changes: 4 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
"[javascript]": {
"editor.formatOnSave": false
},
"eslint.experimental.useFlatConfig": true,
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
"editor.formatOnSave": false
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
}
"editor.formatOnSave": false
}
}
12 changes: 3 additions & 9 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@
"baseUrl": "./",
"paths": {}
},
"include": [
"./src/index.ts"
],
"exclude": [
"**/*.stories.tsx",
"**/*.stories.mdx",
".storybook/**"
]
}
"include": ["./src/index.ts"],
"exclude": ["**/*.stories.tsx", "**/*.stories.mdx", ".storybook/**"]
}
7 changes: 5 additions & 2 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ export default defineConfig({
'@/': new URL('./src/', import.meta.url).pathname,
},
coverage: {
provider: 'istanbul', // or 'v8'
reporter: ['text', 'json', 'html'],
include: ['src/**'],
provider: 'istanbul', // or 'v8'
// you can include other reporters, but 'json-summary' is required, json is recommended
reporter: ['text', 'json-summary', 'json'],
// If you want a coverage reports even if your tests are failing, include the reportOnFailure option
reportOnFailure: true,
},
include: ['**/?(*.){test,spec}.?(c|m)[jt]s?(x)'],
},
Expand Down
6 changes: 2 additions & 4 deletions website/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"extends": "@tsconfig/docusaurus/tsconfig.json",
"compilerOptions": {
"baseUrl": "./",
"types": [
"vitest/globals"
]
"types": ["vitest/globals"]
}
}
}

0 comments on commit 5c54840

Please sign in to comment.