diff --git a/packages/browser/src/client/orchestrator.ts b/packages/browser/src/client/orchestrator.ts index d455732401fb..589856491dd2 100644 --- a/packages/browser/src/client/orchestrator.ts +++ b/packages/browser/src/client/orchestrator.ts @@ -245,7 +245,7 @@ async function getContainer(config: ResolvedConfig): Promise { return document.querySelector('#vitest-tester') as HTMLDivElement } -client.ws.addEventListener('open', async () => { +client.waitForConnection().then(async () => { const testFiles = getBrowserState().files await orchestrator.init() diff --git a/packages/browser/src/client/public/error-catcher.js b/packages/browser/src/client/public/error-catcher.js index a5701f5c8e87..7de41b15d3ed 100644 --- a/packages/browser/src/client/public/error-catcher.js +++ b/packages/browser/src/client/public/error-catcher.js @@ -1,4 +1,4 @@ -import { channel, client } from '/@id/@vitest/browser/client' +import { channel, client } from '@vitest/browser/client' function on(event, listener) { window.addEventListener(event, listener) diff --git a/packages/browser/src/node/plugin.ts b/packages/browser/src/node/plugin.ts index e5517ffa9684..8838f2a7f1c0 100644 --- a/packages/browser/src/node/plugin.ts +++ b/packages/browser/src/node/plugin.ts @@ -166,6 +166,8 @@ export default (browserServer: BrowserServer, base = '/'): Plugin[] => { 'vitest/utils', 'vitest/browser', 'vitest/runners', + '@vitest/browser', + '@vitest/browser/client', '@vitest/utils', '@vitest/utils/source-map', '@vitest/runner', diff --git a/packages/browser/src/node/server.ts b/packages/browser/src/node/server.ts index b552648b9c61..ca7bc8173d6a 100644 --- a/packages/browser/src/node/server.ts +++ b/packages/browser/src/node/server.ts @@ -28,7 +28,7 @@ export class BrowserServer implements IBrowserServer { public testerHtml: Promise | string public orchestratorHtml: Promise | string public injectorJs: Promise | string - public errorCatcherJs: Promise | string + public errorCatcherPath: Promise | string public stateJs: Promise | string public state: BrowserServerState @@ -87,10 +87,7 @@ export class BrowserServer implements IBrowserServer { resolve(distRoot, 'client/esm-client-injector.js'), 'utf8', ).then(js => (this.injectorJs = js)) - this.errorCatcherJs = readFile( - resolve(distRoot, 'client/error-catcher.js'), - 'utf8', - ).then(js => (this.errorCatcherJs = js)) + this.errorCatcherPath = resolve(distRoot, 'client/error-catcher.js') this.stateJs = readFile( resolve(distRoot, 'state.js'), 'utf-8', diff --git a/packages/browser/src/node/serverOrchestrator.ts b/packages/browser/src/node/serverOrchestrator.ts index 07f9b5d90172..cffe6c21d3c8 100644 --- a/packages/browser/src/node/serverOrchestrator.ts +++ b/packages/browser/src/node/serverOrchestrator.ts @@ -73,7 +73,7 @@ export async function resolveOrchestrator( __VITEST_TITLE__: 'Vitest Browser Runner', __VITEST_SCRIPTS__: server.orchestratorScripts, __VITEST_INJECTOR__: ``, - __VITEST_ERROR_CATCHER__: ``, + __VITEST_ERROR_CATCHER__: ``, __VITEST_CONTEXT_ID__: JSON.stringify(contextId), }) } diff --git a/packages/browser/src/node/serverTester.ts b/packages/browser/src/node/serverTester.ts index 3310658459a0..427b0e733139 100644 --- a/packages/browser/src/node/serverTester.ts +++ b/packages/browser/src/node/serverTester.ts @@ -74,7 +74,7 @@ export async function resolveTester( __VITEST_TITLE__: 'Vitest Browser Tester', __VITEST_SCRIPTS__: server.testerScripts, __VITEST_INJECTOR__: ``, - __VITEST_ERROR_CATCHER__: ``, + __VITEST_ERROR_CATCHER__: ``, __VITEST_APPEND__: `