Skip to content

Commit

Permalink
Merge pull request #4 from ieedan/coverage-action
Browse files Browse the repository at this point in the history
feat: adds coverage reporting on PR
  • Loading branch information
ieedan authored Nov 13, 2024
2 parents cf59689 + d47f140 commit a3d2ec3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ jobs:
- name: Lint
run: pnpm check

- name: Lint
run: pnpm test

- name: Build
run: pnpm build

Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: "Test"
on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest

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

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: "20"

- name: Install Deps
run: pnpm install

- name: Test
run: pnpm dlx vitest --coverage.enabled 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
if: always()
uses: davelosert/vitest-coverage-report-action@v2
2 changes: 1 addition & 1 deletion src/utilities/sleep.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ test('Expect time elapsed', async () => {

const end = Date.now();

expect(end - start).toBeGreaterThanOrEqual(duration);
expect(end - start + 10).toBeGreaterThanOrEqual(duration);
});
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
coverage: {
reportOnFailure: true,
provider: 'v8',
reporter: ['json-summary'],
exclude: ['node_modules/', '**/*.d.ts', '**/*.test.ts'],
Expand Down

0 comments on commit a3d2ec3

Please sign in to comment.