From 82f2b50863045e9884dc082a68730178970edc7a Mon Sep 17 00:00:00 2001 From: Vladimir Sheremet Date: Wed, 13 Nov 2024 17:20:11 +0100 Subject: [PATCH] test: don't start the server in watch mode --- test/cli/test/browser-multiple.test.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test/cli/test/browser-multiple.test.ts b/test/cli/test/browser-multiple.test.ts index 3da5e1bf439e..a98eb9f776f5 100644 --- a/test/cli/test/browser-multiple.test.ts +++ b/test/cli/test/browser-multiple.test.ts @@ -1,6 +1,7 @@ +import type { Vitest } from 'vitest/node' import { resolve } from 'pathe' -import { expect, it, onTestFinished, vi } from 'vitest' +import { expect, it, onTestFinished, vi } from 'vitest' import { runVitest } from '../../test-utils' it('automatically assigns the port', async () => { @@ -8,13 +9,24 @@ it('automatically assigns the port', async () => { const workspace = resolve(import.meta.dirname, '../fixtures/browser-multiple/vitest.workspace.ts') const spy = vi.spyOn(console, 'log') onTestFinished(() => spy.mockRestore()) - const { stderr, ctx } = await runVitest({ + let ctx: Vitest + let urls: (string | undefined)[] = [] + const { stderr } = await runVitest({ root, workspace, dir: root, - watch: true, + watch: false, + reporters: [ + { + onInit(ctx_) { + ctx = ctx_ + }, + onFinished() { + urls = ctx.projects.map(p => p.browser?.vite.resolvedUrls?.local[0]) + }, + }, + ], }) - const urls = ctx?.projects.map(p => p.browser?.vite.resolvedUrls?.local[0]) expect(spy).not.toHaveBeenCalled() expect(stderr).not.toContain('is in use, trying another one...')