@@ -4,7 +4,7 @@ import type { ResolvedConfig } from '#types'
4
4
5
5
interface BrowserRunnerOptions {
6
6
config : ResolvedConfig
7
- browserHashMap : Map < string , string >
7
+ browserHashMap : Map < string , [ test : boolean , timstamp : string ] >
8
8
}
9
9
10
10
interface CoverageHandler {
@@ -14,7 +14,7 @@ interface CoverageHandler {
14
14
export function createBrowserRunner ( original : any , coverageModule : CoverageHandler | null ) {
15
15
return class BrowserTestRunner extends original {
16
16
public config : ResolvedConfig
17
- hashMap = new Map < string , string > ( )
17
+ hashMap = new Map < string , [ test : boolean , timstamp : string ] > ( )
18
18
19
19
constructor ( options : BrowserRunnerOptions ) {
20
20
super ( options . config )
@@ -54,15 +54,16 @@ export function createBrowserRunner(original: any, coverageModule: CoverageHandl
54
54
}
55
55
56
56
async importFile ( filepath : string ) {
57
- const match = filepath . match ( / ^ ( \w : \/ ) / )
58
- let hash = this . hashMap . get ( filepath )
59
- if ( ! hash ) {
57
+ let [ test , hash ] = this . hashMap . get ( filepath ) ?? [ false , '' ]
58
+ if ( hash === '' ) {
60
59
hash = Date . now ( ) . toString ( )
61
- this . hashMap . set ( filepath , hash )
60
+ this . hashMap . set ( filepath , [ false , hash ] )
62
61
}
63
- const importpath = match
64
- ? `/@fs/${ filepath . slice ( match [ 1 ] . length ) } ?v=${ hash } `
65
- : `${ filepath } ?v=${ hash } `
62
+
63
+ // on Windows we need the unit to resolve the test file
64
+ const importpath = / ^ \w : / . test ( filepath )
65
+ ? `/@fs/${ filepath } ?${ test ? 'browserv' : 'v' } =${ hash } `
66
+ : `${ filepath } ?${ test ? 'browserv' : 'v' } =${ hash } `
66
67
await import ( importpath )
67
68
}
68
69
}
0 commit comments