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: change the way we initialize isBrowser #3122

Closed
Closed
Changes from all commits
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
4 changes: 2 additions & 2 deletions packages/jest/src/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

const isBrowser = typeof document !== 'undefined'
const isBrowser = () => typeof document !== 'undefined'

function last(arr) {
return arr.length > 0 ? arr[arr.length - 1] : undefined
Expand Down Expand Up @@ -260,7 +260,7 @@ export function getStylesFromClassNames(
}

export function getStyleElements(): Array<HTMLStyleElement> {
if (!isBrowser) {
if (!isBrowser()) {
throw new Error(
'jest-emotion requires jsdom. See https://jestjs.io/docs/en/configuration#testenvironment-string for more information.'
)
Expand Down