@@ -3,7 +3,7 @@ import type { ResolvedConfig } from 'vitest'
3
3
import type { CancelReason , VitestRunner } from '@vitest/runner'
4
4
import type { VitestExecutor } from '../../../vitest/src/runtime/execute'
5
5
import { createBrowserRunner } from './runner'
6
- import { importId } from './utils'
6
+ import { importId as _importId } from './utils'
7
7
import { setupConsoleLogSpy } from './logger'
8
8
import { createSafeRpc , rpc , rpcDone } from './rpc'
9
9
import { setupDialogsSpy } from './dialog'
@@ -24,6 +24,10 @@ const url = new URL(location.href)
24
24
const testId = url . searchParams . get ( 'id' ) || 'unknown'
25
25
const reloadTries = Number ( url . searchParams . get ( 'reloadTries' ) || '0' )
26
26
27
+ const basePath = ( ) => config ?. base || '/'
28
+ const importId = ( id : string ) => _importId ( id , basePath ( ) )
29
+ const viteClientPath = ( ) => `${ basePath ( ) } @vite/client`
30
+
27
31
function getQueryPaths ( ) {
28
32
return url . searchParams . getAll ( 'path' )
29
33
}
@@ -181,15 +185,14 @@ ws.addEventListener('open', async () => {
181
185
const iFrame = document . getElementById ( 'vitest-ui' ) as HTMLIFrameElement
182
186
iFrame . setAttribute ( 'src' , '/__vitest__/' )
183
187
184
- await setupConsoleLogSpy ( )
188
+ await setupConsoleLogSpy ( basePath ( ) )
185
189
setupDialogsSpy ( )
186
190
await runTests ( paths , config ! )
187
191
} )
188
192
189
193
async function prepareTestEnvironment ( config : ResolvedConfig ) {
190
194
// need to import it before any other import, otherwise Vite optimizer will hang
191
- const viteClientPath = '/@vite/client'
192
- await import ( viteClientPath )
195
+ await import ( viteClientPath ( ) )
193
196
194
197
const {
195
198
startTests,
0 commit comments