Skip to content

Commit

Permalink
fix: resolve devtools url after vitest config is resolved
Browse files Browse the repository at this point in the history
resolves #548
  • Loading branch information
danielroe committed Dec 5, 2023
1 parent 053a5df commit 1206db7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ export default defineNuxtModule<NuxtVitestOptions>({
})
})

const PORT = await getPort({ port: 15555 })
const URL = `http://localhost:${PORT}/__vitest__/`
let loaded = false
let promise: Promise<any> | undefined
let ctx: Vitest = undefined!
Expand All @@ -74,6 +72,8 @@ export default defineNuxtModule<NuxtVitestOptions>({
nuxt.callHook('devtools:customTabs:refresh')
}, 100)

let URL: string

async function start() {
const rawViteConfig = mergeConfig({}, await rawViteConfigPromise)

Expand Down Expand Up @@ -102,6 +102,11 @@ export default defineNuxtModule<NuxtVitestOptions>({

const watchMode = !process.env.NUXT_VITEST_DEV_TEST && !isCI

// We resolve the path here to ensure the dev server is already running with the correct protocol
const PORT = await getPort({ port: 15555 })
const PROTOCOL = nuxt.options.devServer.https ? 'https' : 'http'
URL = `${PROTOCOL}://localhost:${PORT}/__vitest__/`

// For testing dev mode in CI, maybe expose an option to user later
const overrides: VitestConfig = watchMode
? {
Expand Down

0 comments on commit 1206db7

Please sign in to comment.