Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vitest/src/node/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export class Vitest {

if (this._cliOptions.browser?.enabled) {
const browserProjects = this.projects.filter(p => p.config.browser.enabled)
if (!browserProjects.length) {
if (!browserProjects.length && !this.config.browser?.instances?.length) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed because instances inject new projects

throw new Error(`Vitest received --browser flag, but no project had a browser configuration.`)
}
}
Expand Down
11 changes: 11 additions & 0 deletions test/cli/test/config/browser-configs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ test('filters projects with a wildcard', async () => {
])
})

test('allows browser mode without projects', async () => {
await vitest({}, {
browser: {
enabled: true,
headless: true,
provider: playwright(),
instances: [{ browser: 'chromium' }],
},
})
})

test('assigns names as browsers in a custom project', async () => {
const { projects } = await vitest({}, {
projects: [
Expand Down
Loading