|
7 | 7 | ignoredLineSet, |
8 | 8 | parseLcov, |
9 | 9 | } from './model.ts'; |
10 | | -import { isInstrumentedPath } from '../coverage-crap/stamp.ts'; |
| 10 | +import { isInstrumentedPath, type CoverageConfig } from '../coverage-crap/stamp.ts'; |
11 | 11 | import { COVERAGE_CONFIG } from './fixtures.ts'; |
12 | 12 |
|
13 | 13 | test('parseLcov reads DA hits and BRDA taken, treating "-" as not taken', () => { |
@@ -235,6 +235,28 @@ test('a stamp-excluded test file or a path outside every include root is not tal |
235 | 235 | assert.equal(result.passed, true); |
236 | 236 | }); |
237 | 237 |
|
| 238 | +test('stamp-excluded test-kit helpers and fixtures files are not tallied', () => { |
| 239 | + // The real stamp excludes these alongside test files (vitest.config.ts), so |
| 240 | + // they are test material, not product logic hiding under an exclude entry. |
| 241 | + const stamp: CoverageConfig = { |
| 242 | + ...COVERAGE_CONFIG, |
| 243 | + exclude: [...COVERAGE_CONFIG.exclude, 'packages/test-kit/**', '**/*.fixtures.ts'], |
| 244 | + }; |
| 245 | + const result = computeChangedCoverage({ |
| 246 | + diffs: [ |
| 247 | + diff('packages/test-kit/src/helper.ts', [1, 2, 3]), |
| 248 | + diff('src/data.fixtures.ts', [1, 2]), |
| 249 | + ], |
| 250 | + coverage, |
| 251 | + stamp, |
| 252 | + fileLines: () => ['const kept = 1;', '', '// a comment'], |
| 253 | + }); |
| 254 | + assert.equal(result.totalLines, 0); |
| 255 | + assert.equal(result.excluded.totalLines, 0); |
| 256 | + assert.deepEqual(result.excluded.files, []); |
| 257 | + assert.equal(result.passed, true); |
| 258 | +}); |
| 259 | + |
238 | 260 | test('changed line suppressed by an ignore directive is tallied, not gated', () => { |
239 | 261 | const cov = parseLcov(['SF:src/x.ts', 'DA:1,1', 'end_of_record'].join('\n')); |
240 | 262 | const result = computeChangedCoverage({ |
|
0 commit comments