Skip to content

Commit

Permalink
fix: issue a warning in conflicting envs (#744)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
Aslemammad and antfu committed Feb 13, 2022
1 parent 51d751c commit 7448e1a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion packages/vitest/src/node/config.ts
@@ -1,4 +1,5 @@
import { resolve } from 'pathe'
import c from 'picocolors'
import type { ResolvedConfig as ResolvedViteConfig } from 'vite'

import type { ApiConfig, ResolvedConfig, UserConfig } from '../types'
Expand Down Expand Up @@ -45,8 +46,24 @@ export function resolveConfig(
options: UserConfig,
viteConfig: ResolvedViteConfig,
): ResolvedConfig {
if (options.dom)
if (options.dom) {
if (
viteConfig.test?.environment != null
&& viteConfig.test!.environment !== 'happy-dom'
) {
console.warn(
c.yellow(
`${c.inverse(c.yellow(' Vitest '))} Your config.test.environment ("${
viteConfig.test.environment
}") conflicts with --dom flag ("happy-dom"), ignoring "${
viteConfig.test.environment
}"`,
),
)
}

options.environment = 'happy-dom'
}

const globals = options?.global ?? options.globals

Expand Down

0 comments on commit 7448e1a

Please sign in to comment.