Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(workspace): throw error when browser mode and @vitest/coverage-v8 are used #5250

Merged
Merged
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
11 changes: 9 additions & 2 deletions packages/vitest/src/node/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,15 @@ export class WorkspaceProject {
}

async setServer(options: UserConfig, server: ViteDevServer) {
this.config = resolveConfig(this.ctx.mode, options, server.config)
this.config = resolveConfig(
sheremet-va marked this conversation as resolved.
Show resolved Hide resolved
this.ctx.mode,
{
...options,
coverage: this.ctx.config.coverage,
},
server.config,
)

this.server = server

this.vitenode = new ViteNodeServer(server, this.config.server)
Expand Down Expand Up @@ -329,7 +337,6 @@ export class WorkspaceProject {

return deepMerge({
...this.config,
coverage: this.ctx.config.coverage,

poolOptions: {
forks: {
Expand Down
13 changes: 13 additions & 0 deletions test/config/fixtures/workspace/browser/workspace-with-browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineWorkspace } from "vitest/config";

export default defineWorkspace([
{
test: {
name: "Browser project",
browser: {
enabled: true,
name: 'chrome'
},
}
}
])
6 changes: 6 additions & 0 deletions test/config/test/failures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ test('v8 coverage provider cannot be used with browser', async () => {
expect(stderr).toMatch('Error: @vitest/coverage-v8 does not work with --browser. Use @vitest/coverage-istanbul instead')
})

test('v8 coverage provider cannot be used with browser in workspace', async () => {
const { stderr } = await runVitest({ coverage: { enabled: true }, workspace: './fixtures/workspace/browser/workspace-with-browser.ts' })

expect(stderr).toMatch('Error: @vitest/coverage-v8 does not work with --browser. Use @vitest/coverage-istanbul instead')
})

test('version number is printed when coverage provider fails to load', async () => {
const { stderr, stdout } = await runVitest({
coverage: {
Expand Down
Loading