Skip to content

Commit

Permalink
test: don't start the server in watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Nov 13, 2024
1 parent 746d898 commit 82f2b50
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions test/cli/test/browser-multiple.test.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
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 () => {
const root = resolve(import.meta.dirname, '../fixtures/browser-multiple')
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...')
Expand Down

0 comments on commit 82f2b50

Please sign in to comment.