From 1b9f3d5c4580d23108b039771d217db00b78b6e9 Mon Sep 17 00:00:00 2001 From: Panagiotis Vourtsis Date: Fri, 3 Nov 2023 14:15:20 +0200 Subject: [PATCH 1/3] fix: change the way we initialize isBrowser --- packages/jest/src/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest/src/utils.js b/packages/jest/src/utils.js index 8a4cad723..98f1f869f 100644 --- a/packages/jest/src/utils.js +++ b/packages/jest/src/utils.js @@ -1,6 +1,6 @@ // @flow -const isBrowser = typeof document !== 'undefined' +const isBrowser = (document) => typeof document !== 'undefined' function last(arr) { return arr.length > 0 ? arr[arr.length - 1] : undefined @@ -260,7 +260,7 @@ export function getStylesFromClassNames( } export function getStyleElements(): Array { - if (!isBrowser) { + if (!isBrowser(document)) { throw new Error( 'jest-emotion requires jsdom. See https://jestjs.io/docs/en/configuration#testenvironment-string for more information.' ) From 59de60ee3a18000f133fd6bc24ff4996467560b6 Mon Sep 17 00:00:00 2001 From: Panagiotis Vourtsis Date: Fri, 3 Nov 2023 14:31:37 +0200 Subject: [PATCH 2/3] chore: removing parenthesis from isBrowser function --- packages/jest/src/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest/src/utils.js b/packages/jest/src/utils.js index 98f1f869f..c085e0133 100644 --- a/packages/jest/src/utils.js +++ b/packages/jest/src/utils.js @@ -1,6 +1,6 @@ // @flow -const isBrowser = (document) => typeof document !== 'undefined' +const isBrowser = document => typeof document !== 'undefined' function last(arr) { return arr.length > 0 ? arr[arr.length - 1] : undefined From bf5e7d048d72cdda65bdc7671371b2fc28f7b6a3 Mon Sep 17 00:00:00 2001 From: Panagiotis Vourtsis Date: Thu, 9 Nov 2023 15:56:02 +0200 Subject: [PATCH 3/3] fix: remove document from isBrowser fn --- packages/jest/src/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/jest/src/utils.js b/packages/jest/src/utils.js index c085e0133..3f900f08f 100644 --- a/packages/jest/src/utils.js +++ b/packages/jest/src/utils.js @@ -1,6 +1,6 @@ // @flow -const isBrowser = document => typeof document !== 'undefined' +const isBrowser = () => typeof document !== 'undefined' function last(arr) { return arr.length > 0 ? arr[arr.length - 1] : undefined @@ -260,7 +260,7 @@ export function getStylesFromClassNames( } export function getStyleElements(): Array { - if (!isBrowser(document)) { + if (!isBrowser()) { throw new Error( 'jest-emotion requires jsdom. See https://jestjs.io/docs/en/configuration#testenvironment-string for more information.' )