Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jan 31, 2024
1 parent a69a87a commit 701b365
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions packages/browser/src/client/tester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const stopErrorHandler = registerUnhandledErrors()

const url = new URL(location.href)

async function prepareTestEnvironment(filenames: string[]) {
async function prepareTestEnvironment(files: string[]) {
await client.waitForConnection()

const config = getConfig()
Expand All @@ -26,12 +26,12 @@ async function prepareTestEnvironment(filenames: string[]) {
}
catch (error) {
await client.rpc.onUnhandledError(error, 'Reload Error')
channel.postMessage({ type: 'done', filenames })
channel.postMessage({ type: 'done', filenames: files })
return
}

if (!rpc) {
channel.postMessage({ type: 'done', filenames })
channel.postMessage({ type: 'done', filenames: files })
return
}

Expand All @@ -47,7 +47,7 @@ async function prepareTestEnvironment(filenames: string[]) {
workerId: 1,
config,
projectName: config.name,
files: filenames,
files,
environment: {
name: 'browser',
options: null,
Expand Down Expand Up @@ -87,7 +87,7 @@ async function prepareTestEnvironment(filenames: string[]) {
const { startTests, setupCommonEnv } = await importId('vitest/browser') as typeof import('vitest/browser')

const version = url.searchParams.get('browserv') || '0'
filenames.forEach((filename) => {
files.forEach((filename) => {
const currentVersion = browserHashMap.get(filename)
if (!currentVersion || currentVersion[1] !== version)
browserHashMap.set(filename, [true, version])
Expand All @@ -108,12 +108,12 @@ async function prepareTestEnvironment(filenames: string[]) {
}
}

async function runTests(filenames: string[]) {
async function runTests(files: string[]) {
let preparedData: Awaited<ReturnType<typeof prepareTestEnvironment>>

// if importing /@id/ failed, we reload the page waiting until Vite prebundles it
try {
preparedData = await prepareTestEnvironment(filenames)
preparedData = await prepareTestEnvironment(files)
}
catch (err) {
location.reload()
Expand All @@ -124,12 +124,12 @@ async function runTests(filenames: string[]) {

try {
await setupCommonEnv(config)
for (const filename of filenames)
await startTests([filename], runner)
for (const file of files)
await startTests([file], runner)
}
finally {
state.environmentTeardownRun = true
channel.postMessage({ type: 'done', filenames })
channel.postMessage({ type: 'done', filenames: files })
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default (project: WorkspaceProject, base = '/'): Plugin[] => {
}
next()
})
server.middlewares.use(async (req, res, next) => {
server.middlewares.use((req, res, next) => {
if (!req.url)
return next()
const url = new URL(req.url, 'http://localhost')
Expand Down

0 comments on commit 701b365

Please sign in to comment.