Skip to content

Commit

Permalink
chore: initialize snapshot environment
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Mar 29, 2023
1 parent e4ec408 commit bb0723e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/browser/src/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { importId } from './utils'
import { setupConsoleLogSpy } from './logger'
import { createSafeRpc, rpc, rpcDone } from './rpc'
import { setupDialogsSpy } from './dialog'
import { BrowserSnapshotEnvironment } from './snapshot'

// @ts-expect-error mocking some node apis
globalThis.process = { env: {}, argv: [], cwd: () => '/', stdout: { write: () => {} }, nextTick: cb => cb() }
Expand Down Expand Up @@ -74,10 +75,10 @@ ws.addEventListener('open', async () => {

await setupConsoleLogSpy()
setupDialogsSpy()
await runTests(paths, config)
await runTests(paths, config!)
})

async function runTests(paths: string[], config: any) {
async function runTests(paths: string[], config: ResolvedConfig) {
// need to import it before any other import, otherwise Vite optimizer will hang
const viteClientPath = '/@vite/client'
await import(viteClientPath)
Expand All @@ -98,6 +99,9 @@ async function runTests(paths: string[], config: any) {
runner = new BrowserRunner({ config, browserHashMap })
}

if (!config.snapshotOptions.snapshotEnvironment)
config.snapshotOptions.snapshotEnvironment = new BrowserSnapshotEnvironment()

try {
await setupCommonEnv(config)
const files = paths.map((path) => {
Expand Down

0 comments on commit bb0723e

Please sign in to comment.