Skip to content

Commit b3aba04

Browse files
authored
Merge pull request #1 from devalbo/cicd-dev
messing with test coverage
2 parents b866361 + c800849 commit b3aba04

File tree

9 files changed

+77
-11
lines changed

9 files changed

+77
-11
lines changed

.github/workflows/pages.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ jobs:
2929
run: npm run lint
3030

3131
- name: Run unit tests
32-
run: npm run test:run
32+
run: npm run coverage:check
33+
34+
- name: CLI smoke test (Node)
35+
env:
36+
TB_SOLID_POD_DATA_PATH: ${{ runner.temp }}/tb-solid-pod-store.json
37+
run: npm run cli:smoke
3338

3439
- name: Generate JSON Schemas
3540
run: npm run generate:schemas

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ dist-ssr
1515
# Editor directories and files
1616
.vscode/*
1717
!.vscode/extensions.json
18+
!.vscode/settings.json
19+
!.vscode/tasks.json
1820
.idea
1921
.DS_Store
2022
*.suo
@@ -31,3 +33,6 @@ storybook-static
3133
test-results
3234
playwright-report
3335
playwright/.cache
36+
37+
# Vitest coverage output
38+
coverage

.vscode/settings.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Make editor diagnostics match CI scripts:
3+
// - Lint: ESLint (npm run lint)
4+
// - Types: TypeScript language service (same tsconfig as npm run typecheck)
5+
"eslint.useFlatConfig": true,
6+
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
7+
"eslint.workingDirectories": [{ "mode": "auto" }],
8+
"eslint.run": "onType",
9+
"editor.codeActionsOnSave": {
10+
"source.fixAll.eslint": "never"
11+
},
12+
// Ensure VS Code uses the workspace TypeScript (same as tsc in scripts)
13+
"typescript.tsdk": "node_modules/typescript/lib",
14+
"typescript.enablePromptUseWorkspaceTsdk": true
15+
}
16+

.vscode/tasks.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "tb-solid-pod: check (lint + typecheck + tests)",
6+
"type": "shell",
7+
"command": "npm run check",
8+
"group": "build",
9+
"problemMatcher": []
10+
}
11+
]
12+
}
13+

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ exit Exit the CLI (Node terminal only)
230230
## Testing
231231

232232
- **Unit tests (Vitest):** `npm test` or `npm run test:run`; coverage: `npm run test:coverage`
233+
- **Coverage report:** `npm run test:coverage` generates:
234+
- terminal summary
235+
- HTML report at `coverage/index.html`
236+
- lcov at `coverage/lcov.info` (for CI tooling)
233237
- **Storybook:** `npm run storybook`http://localhost:6006 (component development). See [docs/testing/](docs/testing/README.md).
234238
- **BDD / E2E (Playwright):** Generate specs from Gherkin, then run Playwright:
235239
```bash

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import reactRefresh from 'eslint-plugin-react-refresh';
88
import { defineConfig, globalIgnores } from 'eslint/config';
99

1010
export default defineConfig([
11-
globalIgnores(['dist', '.features-gen']),
11+
globalIgnores(['dist', '.features-gen', 'coverage']),
1212
// Node/Config files: process etc.
1313
{
1414
files: ['vite.config.js', 'vitest.config.ts', 'playwright.config.ts'],

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@
4040
"test": "vitest",
4141
"test:run": "vitest run",
4242
"test:ui": "vitest --ui",
43-
"test:coverage": "vitest --coverage",
43+
"test:coverage": "vitest run --coverage",
44+
"coverage:check": "vitest run --coverage --config vitest.coverage-check.config.ts",
4445
"storybook": "storybook dev -p 6006",
4546
"build-storybook": "storybook build",
4647
"test:e2e": "npx bddgen && playwright test",
4748
"test:e2e:headed": "npx bddgen && playwright test --headed",
4849
"test:e2e:terminal": "vitest run --config vitest.terminal-e2e.config.ts",
4950
"test:bdd": "npx bddgen && playwright test",
50-
"cli": "tsx src/cli/run-node.tsx"
51+
"cli": "tsx src/cli/run-node.tsx",
52+
"cli:smoke": "node --import tsx src/cli/run-node.tsx help && node --import tsx src/cli/run-node.tsx pwd && node --import tsx src/cli/run-node.tsx ls"
5153
},
5254
"dependencies": {
5355
"@inrupt/vocab-common-rdf": "^1.0.5",

vitest.config.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@ export default defineConfig({
1111
exclude: ['tests/terminal/**', 'tests/e2e-cli-terminal.spec.ts'],
1212
coverage: {
1313
provider: 'v8',
14-
reporter: ['text', 'json', 'html'],
14+
reportsDirectory: './coverage',
15+
reporter: ['text', 'json', 'json-summary', 'html', 'lcov'],
1516
include: ['src/**/*.{ts,tsx}'],
1617
exclude: [
18+
// Demo app & UI components (coverage focuses on the library/CLI layers)
19+
'src/App.tsx',
20+
'src/components/**/*.{ts,tsx}',
21+
'src/examples/**/*.{ts,tsx}',
1722
'src/**/*.stories.{ts,tsx}',
1823
'src/main.tsx',
1924
'src/index.ts',
2025
'src/**/*.d.ts',
2126
],
22-
thresholds: {
23-
lines: 80,
24-
functions: 80,
25-
branches: 80,
26-
statements: 80,
27-
},
2827
},
2928
},
3029
})

vitest.coverage-check.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineConfig } from 'vitest/config';
2+
import base from './vitest.config';
3+
4+
// CI/quality gate: enforce minimum coverage thresholds (global).
5+
export default defineConfig({
6+
...(base as unknown as Record<string, unknown>),
7+
test: {
8+
// @ts-expect-error - base config shape is compatible at runtime
9+
...(base.test ?? {}),
10+
coverage: {
11+
// @ts-expect-error - base config shape is compatible at runtime
12+
...(base.test?.coverage ?? {}),
13+
thresholds: {
14+
lines: 20,
15+
functions: 20,
16+
branches: 20,
17+
statements: 20,
18+
},
19+
},
20+
},
21+
});
22+

0 commit comments

Comments
 (0)