6 files changed +49
-1
lines changed Original file line number Diff line number Diff line change @@ -125,7 +125,6 @@ export class VitestTestRunner implements VitestRunner {
125
125
isExpectingAssertionsError : null ,
126
126
expectedAssertionsNumber : null ,
127
127
expectedAssertionsNumberErrorGen : null ,
128
- testPath : test . file . filepath ,
129
128
currentTestName : getTestName ( test ) ,
130
129
snapshotState : this . snapshotClient . getSnapshotState ( test . file . filepath ) ,
131
130
} ,
Original file line number Diff line number Diff line change
1
+ import { expect , test } from 'vitest'
2
+
3
+ const testPath = expect . getState ( ) . testPath ;
4
+
5
+ test ( "a" , ( ) => {
6
+ expect ( testPath ) . toContain ( 'a.test.ts' )
7
+ } )
Original file line number Diff line number Diff line change
1
+ import { expect , test } from 'vitest'
2
+
3
+ const testPath = expect . getState ( ) . testPath ;
4
+
5
+ test ( "b" , ( ) => {
6
+ expect ( testPath ) . toContain ( 'b.test.ts' )
7
+ } )
Original file line number Diff line number Diff line change
1
+ import { expect , test } from 'vitest'
2
+
3
+ const testPath = expect . getState ( ) . testPath ;
4
+
5
+ test ( "c" , ( ) => {
6
+ expect ( testPath ) . toContain ( 'c.test.ts' )
7
+ } )
Original file line number Diff line number Diff line change
1
+ import { defineConfig } from "vitest/config" ;
2
+
3
+ export default defineConfig ( {
4
+ test : {
5
+ isolate : false ,
6
+ minWorkers : 1 ,
7
+ maxWorkers : 1 ,
8
+ }
9
+ } )
Original file line number Diff line number Diff line change
1
+ import type { UserConfig } from 'vitest/node'
2
+ import { expect , test } from 'vitest'
3
+ import { runVitest } from '../../test-utils'
4
+
5
+ test . for ( [
6
+ { isolate : true } ,
7
+ { isolate : false , minWorkers : 1 , maxWorkers : 1 } ,
8
+ { isolate : false , fileParallelism : false } ,
9
+ { isolate : false , poolOptions : { forks : { singleFork : true } } } ,
10
+ ] satisfies UserConfig [ ] ) ( `getState().testPath during collection %s` , async ( config ) => {
11
+ const result = await runVitest ( {
12
+ root : './fixtures/get-state' ,
13
+ ...config ,
14
+ } )
15
+ expect ( result . stderr ) . toBe ( '' )
16
+ expect ( result . stdout ) . toContain ( '✓ a.test.ts' )
17
+ expect ( result . stdout ) . toContain ( '✓ b.test.ts' )
18
+ expect ( result . stdout ) . toContain ( '✓ c.test.ts' )
19
+ } )
0 commit comments