Skip to content

Commit 3cc095b

Browse files
authored
test: improve DX (#1129)
1 parent 6f6cd0e commit 3cc095b

File tree

8 files changed

+91
-55
lines changed

8 files changed

+91
-55
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ jobs:
1212
verifications:
1313
name: Verifications
1414
uses: ./.github/workflows/verifications.yml
15-
secrets:
16-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1715

1816
required-checks:
1917
name: Require CI status checks

.github/workflows/main-coverage.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ permissions:
2222
pull-requests: write # to be able to comment on released pull requests
2323

2424
jobs:
25+
verifications:
26+
name: Verifications
27+
uses: ./.github/workflows/verifications.yml
28+
2529
publish:
2630
name: Publish package
2731
runs-on: ubuntu-latest
32+
needs: [verifications]
2833
# Avoid publishing in forks
2934
if: github.repository == 'testing-library/eslint-plugin-testing-library'
3035
steps:

.github/workflows/verifications.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Verifications
22

33
on:
44
workflow_call:
5-
secrets:
6-
CODECOV_TOKEN:
7-
required: true
5+
6+
permissions:
7+
id-token: write # OIDC auth for Codecov
88

99
jobs:
1010
code-validation:
@@ -65,7 +65,16 @@ jobs:
6565
- name: Run tests
6666
run: pnpm run test:ci
6767

68-
- name: Upload coverage reports to Codecov
68+
- name: Upload tests coverage report
6969
uses: codecov/codecov-action@v5
70-
env:
71-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
70+
if: ${{ !cancelled() && github.event.action != 'closed' }}
71+
with:
72+
use_oidc: true
73+
report_type: 'coverage'
74+
75+
- name: Upload tests result report
76+
uses: codecov/codecov-action@v5
77+
if: ${{ !cancelled() && github.event.action != 'closed' }}
78+
with:
79+
use_oidc: true
80+
report_type: 'test_results'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pids
1616

1717
# Directory for instrumented libs generated by jscoverage/JSCover
1818
lib-cov
19+
test-report.junit.xml
1920

2021
# Coverage directory used by tools like istanbul
2122
coverage
@@ -64,6 +65,7 @@ typings/
6465
yarn-error.log
6566
.pnp/
6667
.pnp.js
68+
6769
# Yarn Integrity file
6870
.yarn-integrity
6971

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"semantic-release": "semantic-release",
5050
"test": "vitest run",
5151
"test:ci": "vitest run --coverage",
52+
"test:ui": "vitest --ui",
5253
"test:watch": "vitest",
5354
"type-check": "tsc --noEmit"
5455
},
@@ -66,6 +67,7 @@
6667
"@typescript-eslint/rule-tester": "^8.15.0",
6768
"@vitest/coverage-v8": "^3.2.4",
6869
"@vitest/eslint-plugin": "^1.5.2",
70+
"@vitest/ui": "3.2.4",
6971
"del-cli": "^6.0.0",
7072
"eslint": "^9.35.0",
7173
"eslint-config-prettier": "^10.1.8",

pnpm-lock.yaml

Lines changed: 60 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vitest.config.mts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { defineConfig } from 'vitest/config';
1+
import { defineConfig, configDefaults } from 'vitest/config';
22

33
export default defineConfig({
44
test: {
55
include: ['**/tests/**/*.test.ts'],
66
setupFiles: ['./vitest.setup.mts'],
7+
clearMocks: true,
78
coverage: {
89
include: ['lib/**'],
910
thresholds: {
@@ -13,5 +14,10 @@ export default defineConfig({
1314
statements: 90,
1415
},
1516
},
17+
// Enable JUnit reporter in CI environment
18+
reporters: process.env.CI ? ['default', 'junit'] : configDefaults.reporters,
19+
outputFile: {
20+
junit: 'test-report.junit.xml',
21+
},
1622
},
1723
});

0 commit comments

Comments
 (0)