mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
chore(packages): add test coverage support to plugin sdk and shared package
This commit is contained in:
@@ -78,7 +78,50 @@ jobs:
|
||||
run: cd shared && npm run typecheck
|
||||
|
||||
- name: Run tests
|
||||
run: cd shared && npm test
|
||||
run: cd shared && npm run test:coverage
|
||||
|
||||
- name: Upload coverage
|
||||
if: success()
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: shared-coverage
|
||||
path: shared/coverage/
|
||||
retention-days: 7
|
||||
|
||||
plugin-sdk-tests:
|
||||
name: Plugin SDK Tests
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: plugin-sdk
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-node@v6
|
||||
with:
|
||||
# 22 matches the TREK server runtime and has node:sqlite, which the
|
||||
# dev-server tests exercise (same choice as publish-plugin-sdk.yml).
|
||||
node-version: 22
|
||||
|
||||
# plugin-sdk is standalone (own lockfile, not a root workspace), so it
|
||||
# installs from its own directory.
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Typecheck
|
||||
run: npm run typecheck
|
||||
|
||||
- name: Run tests
|
||||
run: npm run test:coverage
|
||||
|
||||
- name: Upload coverage
|
||||
if: success()
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: plugin-sdk-coverage
|
||||
path: plugin-sdk/coverage/
|
||||
retention-days: 7
|
||||
|
||||
server-tests:
|
||||
name: Server Tests
|
||||
|
||||
@@ -34,7 +34,7 @@ npm run test:unit --workspace=server # tests/unit only
|
||||
npm run test:integration --workspace=server
|
||||
npm run test:ws --workspace=server # websocket tests
|
||||
npm run test:e2e # server e2e (boots Nest against temp SQLite)
|
||||
npm run test:cov # coverage, server + client
|
||||
npm run test:cov # coverage (lcov), all four packages incl. shared + plugin-sdk
|
||||
cd client && npm run test # client vitest run
|
||||
cd client && npm run e2e # Playwright
|
||||
cd client && npm run lint:pages # enforce the Page pattern (see below)
|
||||
|
||||
Generated
+1
@@ -22084,6 +22084,7 @@
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
||||
"@vitest/coverage-v8": "^4.1.9",
|
||||
"eslint": "^10.3.0",
|
||||
"eslint-config-flat-gitignore": "^2.3.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
"dev": "npm run build --workspace=shared && concurrently --names shared,server,client \"npm run build:watch --workspace=shared\" \"npm run dev --workspace=server\" \"npm run dev --workspace=client\"",
|
||||
"build": "npm run build --workspace=shared && npm run build --workspace=server && npm run build --workspace=client",
|
||||
"test": "npm run test --workspace=shared && npm run test --workspace=server && npm run test --workspace=client",
|
||||
"test:cov": "npm run test:coverage --workspace=server && npm run test:coverage --workspace=client",
|
||||
"test:cov": "npm run test:coverage --workspace=shared && npm run test:coverage --workspace=server && npm run test:coverage --workspace=client && npm run test:coverage --prefix plugin-sdk",
|
||||
"test:e2e": "npm run test:e2e --workspace=server",
|
||||
"lint": "npm run lint --workspace=shared && npm run lint --workspace=server && npm run lint --workspace=client",
|
||||
"format": "npm run format --workspace=shared && npm run format --workspace=server && npm run format --workspace=client",
|
||||
|
||||
Generated
+440
-255
File diff suppressed because it is too large
Load Diff
@@ -71,12 +71,14 @@
|
||||
"build": "tsc -p tsconfig.json && tsc -p tsconfig.cjs.json && node scripts/finish-cjs.mjs",
|
||||
"typecheck": "tsc -p tsconfig.json --noEmit",
|
||||
"test": "vitest run",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"prepublishOnly": "npm run build && npm test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.20.0",
|
||||
"@types/semver": "^7.7.1",
|
||||
"@types/update-notifier": "^6.0.8",
|
||||
"@vitest/coverage-v8": "^4.1.9",
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^4.1.9"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
coverage: {
|
||||
provider: 'v8',
|
||||
reporter: ['lcov', 'text'],
|
||||
reportsDirectory: './coverage',
|
||||
include: ['src/**/*.ts'],
|
||||
// Mirrored in the repo root's sonar.coverage.exclusions — a file skipped
|
||||
// here emits no lcov entry, so Sonar must not count it as uncovered either.
|
||||
exclude: [
|
||||
// Machine-written by server/scripts/gen-plugin-facts.ts.
|
||||
'src/generated/**',
|
||||
// Generated snapshot (scripts/gen-lucide-icon-names.mjs) — pure data.
|
||||
'src/lucide-icon-names.ts',
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -54,6 +54,7 @@
|
||||
"build:watch": "tsdown --watch --no-clean",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"format": "prettier --write \"src/**/*.ts\"",
|
||||
"format:check": "prettier --check \"src/**/*.ts\"",
|
||||
@@ -68,6 +69,7 @@
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
||||
"@vitest/coverage-v8": "^4.1.9",
|
||||
"eslint": "^10.3.0",
|
||||
"eslint-config-flat-gitignore": "^2.3.0",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
coverage: {
|
||||
provider: 'v8',
|
||||
reporter: ['lcov', 'text'],
|
||||
reportsDirectory: './coverage',
|
||||
include: ['src/**/*.ts'],
|
||||
// Mirrored in sonar.coverage.exclusions — a file skipped here emits no
|
||||
// lcov entry, so Sonar must not count it as uncovered either.
|
||||
exclude: [
|
||||
// Machine-generated by server/scripts/gen-plugin-facts.ts.
|
||||
'src/plugin-permissions.ts',
|
||||
// Per-locale string tables are data, not executable code; the parity
|
||||
// specs import every locale, which would report them as 100% covered
|
||||
// and inflate the package number.
|
||||
'src/i18n/*/**',
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -30,14 +30,17 @@ sonar.exclusions=\
|
||||
**/*.spec.ts,\
|
||||
**/*.d.ts
|
||||
|
||||
# Coverage — lcov paths relative to repo root.
|
||||
# shared/ and plugin-sdk/ have test suites but don't emit lcov (no coverage
|
||||
# reporter configured); their sources are coverage-excluded below until they do.
|
||||
# Coverage — lcov paths relative to repo root, one per package
|
||||
# (each package's vitest config emits lcov to <pkg>/coverage/).
|
||||
sonar.javascript.lcov.reportPaths=\
|
||||
server/coverage/lcov.info,\
|
||||
client/coverage/lcov.info
|
||||
client/coverage/lcov.info,\
|
||||
shared/coverage/lcov.info,\
|
||||
plugin-sdk/coverage/lcov.info
|
||||
|
||||
# Infrastructure/bootstrap files and packages without coverage instrumentation
|
||||
# Infrastructure/bootstrap files plus generated/data files the vitest configs
|
||||
# exclude from instrumentation (a file absent from lcov would otherwise count
|
||||
# as 0% covered here — keep these in sync with each package's vitest.config.ts)
|
||||
sonar.coverage.exclusions=\
|
||||
server/src/index.ts,\
|
||||
server/src/config.ts,\
|
||||
@@ -48,8 +51,10 @@ sonar.coverage.exclusions=\
|
||||
server/src/nest/plugins/runtime/plugin-host-entry.ts,\
|
||||
client/src/main.tsx,\
|
||||
client/src/types.ts,\
|
||||
shared/src/**,\
|
||||
plugin-sdk/src/**
|
||||
shared/src/plugin-permissions.ts,\
|
||||
shared/src/i18n/*/**,\
|
||||
plugin-sdk/src/generated/**,\
|
||||
plugin-sdk/src/lucide-icon-names.ts
|
||||
|
||||
# Locale files are large near-identical literal objects — keep them out of duplication metrics
|
||||
sonar.cpd.exclusions=shared/src/i18n/**
|
||||
|
||||
Reference in New Issue
Block a user