Skip to content

Commit c01adc2

Browse files
committed
ci: headless tests with coverage and OpenAPI contract validation
- twd-cli, vite-plugin-istanbul and nyc as devDependencies - twd.config.json points puppeteer at :3000, instruments coverage to ./coverage / .nyc_output and validates mocks against contracts/todos-3.0.json (strict, error mode, /api baseUrl) - vite.config.ts wires vite-plugin-istanbul (requireEnv off in CI) - npm scripts: dev:ci, test:ci, collect:coverage:{text,html,lcov} - GitHub Actions workflow boots dev:ci, runs the BRIKEV/twd-cli action with contract-report enabled, then prints text coverage; granted pull-requests: write so the action can post the contract summary
1 parent 0ed0fb9 commit c01adc2

6 files changed

Lines changed: 2484 additions & 59 deletions

File tree

.github/workflows/ci.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,42 @@ name: CI - twd tests
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
8+
9+
permissions:
10+
pull-requests: write
811

912
jobs:
1013
test:
1114
runs-on: ubuntu-latest
1215

1316
steps:
14-
- name: Checkout repository
15-
uses: actions/checkout@v5
17+
- uses: actions/checkout@v5
1618

17-
- name: Setup Node.js
18-
uses: actions/setup-node@v5
19+
- uses: actions/setup-node@v5
1920
with:
2021
node-version: 24
21-
cache: 'npm'
22+
cache: npm
2223

2324
- name: Install dependencies
2425
run: npm ci
2526

26-
- name: Start Vite dev server
27+
- name: Install mock service worker
28+
run: npx twd-js init public --save
29+
30+
- name: Start dev server
2731
run: |
28-
nohup npm run dev > vite.log 2>&1 &
29-
npx wait-on http://localhost:5173
32+
nohup npm run dev:ci > /dev/null 2>&1 &
33+
npx wait-on http://localhost:3000
3034
env:
3135
CI: true
36+
37+
- name: Run TWD tests
38+
uses: BRIKEV/twd-cli/.github/actions/run@main
39+
with:
40+
contract-report: 'true'
41+
42+
- name: Display coverage
43+
run: npm run collect:coverage:text

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ dist-ssr
1111
.vinxi
1212
__unconfig*
1313
todos.json
14+
coverage
15+
.nyc_output
16+
.twd

0 commit comments

Comments
 (0)