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

Check vitest global for @emotion/react loaded twice warning #2905

Merged
merged 2 commits into from Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/loud-dancers-return.md
@@ -0,0 +1,5 @@
---
'@emotion/react': patch
---

Include vitest global check when omitting the warning about duplicate instantiation in mocked modules. Will only capture vitest global `vi` if globals are configured.
Andarist marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions flow-typed/npm/vitest_vx.x.x.js
@@ -0,0 +1 @@
declare var vi: {}
4 changes: 2 additions & 2 deletions packages/react/src/index.js
Expand Up @@ -17,9 +17,9 @@ export { default as css } from './css'
if (process.env.NODE_ENV !== 'production') {
const isBrowser = typeof document !== 'undefined'
// #1727 for some reason Jest evaluates modules twice if some consuming module gets mocked with jest.mock
Andarist marked this conversation as resolved.
Show resolved Hide resolved
const isJest = typeof jest !== 'undefined'
const isTestEnv = typeof jest !== 'undefined' || typeof vi !== 'undefined'

if (isBrowser && !isJest) {
if (isBrowser && !isTestEnv) {
// globalThis has wide browser support - https://caniuse.com/?search=globalThis, Node.js 12 and later
const globalContext =
// $FlowIgnore
Expand Down