-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(browser): increment browser port automatically if there are sever…
…al projects with browser.enabled (#6717)
- Loading branch information
1 parent
da6d2ea
commit a939779
Showing
8 changed files
with
75 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "browser-multiple" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { resolve } from 'pathe'; | ||
import { defineWorkspace } from 'vitest/config'; | ||
|
||
export default defineWorkspace([ | ||
{ | ||
cacheDir: resolve(import.meta.dirname, 'basic-1'), | ||
test: { | ||
name: 'basic-1', | ||
include: ['none'], | ||
browser: { | ||
enabled: true, | ||
name: 'chromium', | ||
provider: 'playwright', | ||
headless: true, | ||
} | ||
} | ||
}, | ||
{ | ||
cacheDir: resolve(import.meta.dirname, 'basic-2'), | ||
test: { | ||
name: 'basic-2', | ||
include: ['none'], | ||
browser: { | ||
enabled: true, | ||
name: 'chromium', | ||
provider: 'playwright', | ||
headless: true, | ||
} | ||
} | ||
}, | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { resolve } from 'pathe' | ||
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, stdout } = await runVitest({ | ||
root, | ||
workspace, | ||
dir: root, | ||
watch: false, | ||
}) | ||
|
||
expect(spy).not.toHaveBeenCalled() | ||
expect(stderr).not.toContain('is in use, trying another one...') | ||
expect(stdout).toContain('Browser runner started by playwright at http://localhost:63315/') | ||
expect(stdout).toContain('Browser runner started by playwright at http://localhost:63316/') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters