Skip to content

Commit b2f4467

Browse files
poltorakSzymon.Poltorak
andauthored
refactor: remove noise files from test coverage (#1214)
Covers part 3 of #1168 Added more files to be excluded in test coverage report --------- Co-authored-by: Szymon.Poltorak <szymon.poltorak@push-based.io>
1 parent 0280600 commit b2f4467

File tree

5 files changed

+67
-5
lines changed

5 files changed

+67
-5
lines changed

packages/utils/mocks/sink.mock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Sink } from '../src/lib/sink-source.types';
1+
import type { Sink } from '../src/lib/sink-source.type';
22

33
export class MockSink implements Sink<string, string> {
44
private writtenItems: string[] = [];

packages/utils/src/lib/performance-observer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
type PerformanceObserverEntryList,
55
performance,
66
} from 'node:perf_hooks';
7-
import type { Buffered, Encoder, Observer, Sink } from './sink-source.types.js';
7+
import type { Buffered, Encoder, Observer, Sink } from './sink-source.type';
88

99
const OBSERVED_TYPES = ['mark', 'measure'] as const;
1010
type ObservedEntryType = 'mark' | 'measure';
File renamed without changes.

testing/test-setup-config/src/lib/vitest-config-factory.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,33 @@ function buildCoverageConfig(
3131
return undefined;
3232
}
3333

34-
const exclude = ['mocks/**', '**/types.ts', 'perf/**'];
34+
const exclude = [
35+
'tests/**',
36+
'perf/**',
37+
// Mocks and fixtures
38+
'mocks/**',
39+
'**/fixtures/**',
40+
'**/*.mock.ts',
41+
'**/*.fixture.ts',
42+
// Config files
43+
'**/vitest.*.config.ts',
44+
'**/vitest.config.ts',
45+
'**/code-pushup.config.ts',
46+
'**/*.config.ts',
47+
// Barrel files (index files that only re-export)
48+
'**/index.ts',
49+
'**/index.js',
50+
'**/index.mjs',
51+
// Model files
52+
'**/models.ts',
53+
'**/*.model.ts',
54+
'**/types.ts',
55+
'**/*.type.ts',
56+
// Constants
57+
'**/constants.ts',
58+
// typings
59+
'**/*.d.ts',
60+
];
3561
const reportsDirectory = `../../coverage/${projectKey}/${kind}-tests`;
3662

3763
return {

testing/test-setup-config/src/lib/vitest-config-factory.unit.test.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,27 @@ describe('createVitestConfig', () => {
3838
coverage: expect.objectContaining({
3939
reporter: ['text', 'lcov'],
4040
reportsDirectory: '../../coverage/test-package/unit-tests',
41-
exclude: ['mocks/**', '**/types.ts', 'perf/**'],
41+
exclude: [
42+
'tests/**',
43+
'perf/**',
44+
'mocks/**',
45+
'**/fixtures/**',
46+
'**/*.mock.ts',
47+
'**/*.fixture.ts',
48+
'**/vitest.*.config.ts',
49+
'**/vitest.config.ts',
50+
'**/code-pushup.config.ts',
51+
'**/*.config.ts',
52+
'**/index.ts',
53+
'**/index.js',
54+
'**/index.mjs',
55+
'**/models.ts',
56+
'**/*.model.ts',
57+
'**/types.ts',
58+
'**/*.type.ts',
59+
'**/constants.ts',
60+
'**/*.d.ts',
61+
],
4262
}),
4363
typecheck: { include: ['**/*.type.test.ts'] },
4464
}),
@@ -270,9 +290,25 @@ describe('createVitestConfig', () => {
270290
const config = createVitestConfig('test-package', 'unit');
271291

272292
expect(config.test!.coverage!.exclude).toEqual([
293+
'tests/**',
294+
'perf/**',
273295
'mocks/**',
296+
'**/fixtures/**',
297+
'**/*.mock.ts',
298+
'**/*.fixture.ts',
299+
'**/vitest.*.config.ts',
300+
'**/vitest.config.ts',
301+
'**/code-pushup.config.ts',
302+
'**/*.config.ts',
303+
'**/index.ts',
304+
'**/index.js',
305+
'**/index.mjs',
306+
'**/models.ts',
307+
'**/*.model.ts',
274308
'**/types.ts',
275-
'perf/**',
309+
'**/*.type.ts',
310+
'**/constants.ts',
311+
'**/*.d.ts',
276312
]);
277313
});
278314
});

0 commit comments

Comments
 (0)