diff --git a/package.json b/package.json index e64b6393..7a96610d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "precheck:links": "npm run build", "seq": "bash -c 'for cmd in \"$@\"; do npm run $cmd || exit 1; done' - ", "serve": "npm run docus:serve", - "test:coverage": "c8 --reporter=text --reporter=lcov --reporter=json-summary --exclude 'docusaurus.config.ts' --exclude 'lib/testHelpers/**' --check-coverage --lines 100 --statements 100 --branches 100 --functions 100 npm run test:unit", + "test:coverage": "c8 --reporter=text --reporter=lcov --reporter=json-summary --exclude 'lib/testHelpers/**' --check-coverage --lines 100 --statements 100 --branches 100 --functions 100 npm run test:unit", "report:coverage-summary": "node scripts/coverage-summary.mjs", "test:e2e": "node --test 'e2e/**/*.test.mjs'", "test:unit": "node --experimental-strip-types --experimental-test-module-mocks --test 'lib/**/*.test.mts' 'scripts/**/*.test.mjs'", diff --git a/scripts/coverage-thresholds.test.mjs b/scripts/coverage-thresholds.test.mjs index fbbc0e25..bedb2e89 100644 --- a/scripts/coverage-thresholds.test.mjs +++ b/scripts/coverage-thresholds.test.mjs @@ -25,3 +25,21 @@ test('test:coverage enforces 100% coverage thresholds', async () => { ); } }); + +// docusaurus.config.ts is fully exercised by +// lib/docusaurusConfigPreprocessor.test.mts and +// lib/docusaurusConfigBuildContext.test.mts (both import the real file via +// testHelpers/resolveExtensionlessTs.mjs), so excluding it from the c8 gate +// is a stale blind spot: new untested code added to that file would pass +// `npm run test:coverage` silently instead of failing it. +test('test:coverage does not exclude docusaurus.config.ts from the gate', async () => { + const packageJsonPath = path.resolve('package.json'); + const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf-8')); + const script = packageJson.scripts['test:coverage']; + + assert.ok(script, 'test:coverage script must exist in package.json'); + assert.ok( + !script.includes('docusaurus.config.ts'), + 'test:coverage should not --exclude docusaurus.config.ts; it is unit-tested and should be gated', + ); +});