Skip to content

Commit 1206db7

Browse files
committedDec 5, 2023
fix: resolve devtools url after vitest config is resolved
resolves #548
1 parent 053a5df commit 1206db7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

Diff for: ‎src/module.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ export default defineNuxtModule<NuxtVitestOptions>({
6363
})
6464
})
6565

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

75+
let URL: string
76+
7777
async function start() {
7878
const rawViteConfig = mergeConfig({}, await rawViteConfigPromise)
7979

@@ -102,6 +102,11 @@ export default defineNuxtModule<NuxtVitestOptions>({
102102

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

105+
// We resolve the path here to ensure the dev server is already running with the correct protocol
106+
const PORT = await getPort({ port: 15555 })
107+
const PROTOCOL = nuxt.options.devServer.https ? 'https' : 'http'
108+
URL = `${PROTOCOL}://localhost:${PORT}/__vitest__/`
109+
105110
// For testing dev mode in CI, maybe expose an option to user later
106111
const overrides: VitestConfig = watchMode
107112
? {

0 commit comments

Comments
 (0)
Please sign in to comment.