File tree 2 files changed +28
-3
lines changed
packages/vitest/src/node/config 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -349,16 +349,23 @@ export function resolveConfig(
349
349
resolved . globalSetup = toArray ( resolved . globalSetup || [ ] ) . map ( file =>
350
350
resolvePath ( file , resolved . root ) ,
351
351
)
352
- resolved . coverage . exclude . push (
352
+
353
+ // override original exclude array for cases where user re-uses same object in test.exclude
354
+ resolved . coverage . exclude = [
355
+ ...resolved . coverage . exclude ,
356
+
357
+ // Exclude setup files
353
358
...resolved . setupFiles . map (
354
359
file =>
355
360
`${ resolved . coverage . allowExternal ? '**/' : '' } ${ relative (
356
361
resolved . root ,
357
362
file ,
358
363
) } `,
359
364
) ,
360
- )
361
- resolved . coverage . exclude . push ( ...resolved . include )
365
+
366
+ // Exclude test files
367
+ ...resolved . include ,
368
+ ]
362
369
363
370
resolved . forceRerunTriggers = [
364
371
...resolved . forceRerunTriggers ,
Original file line number Diff line number Diff line change @@ -42,3 +42,21 @@ test('respects custom config', async () => {
42
42
expect ( vitestConfig . name ) . toBe ( 'custom config' )
43
43
expect ( vitestConfig . reporters ) . toEqual ( [ [ 'default' , { } ] ] )
44
44
} )
45
+
46
+ test ( 'default value changes of coverage.exclude do not reflect to test.exclude' , async ( ) => {
47
+ const exclude = [ '**/custom-exclude/**' ]
48
+
49
+ const { vitestConfig } = await resolveConfig ( {
50
+ include : [ '**/example.test.ts' ] ,
51
+ exclude,
52
+ coverage : {
53
+ exclude,
54
+ } ,
55
+ } )
56
+
57
+ expect ( exclude ) . toStrictEqual ( [ '**/custom-exclude/**' ] )
58
+
59
+ expect ( vitestConfig . include ) . toStrictEqual ( [ '**/example.test.ts' ] )
60
+ expect ( vitestConfig . exclude ) . toStrictEqual ( [ '**/custom-exclude/**' ] )
61
+ expect ( vitestConfig . coverage . exclude ) . toStrictEqual ( [ '**/custom-exclude/**' , '**/example.test.ts' ] )
62
+ } )
You can’t perform that action at this time.
0 commit comments