From de24efad669ee5ee7099457442773654259a0c9e Mon Sep 17 00:00:00 2001 From: Lorenzo Sciandra Date: Thu, 13 Oct 2022 16:49:26 +0100 Subject: [PATCH 1/3] add a custom react-native jest env --- jest-preset.js | 2 +- jest/react-native-env.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 jest/react-native-env.js diff --git a/jest-preset.js b/jest-preset.js index e49c4062687ea5..d1a749c5a2701a 100644 --- a/jest-preset.js +++ b/jest-preset.js @@ -24,5 +24,5 @@ module.exports = { 'node_modules/(?!((jest-)?react-native|@react-native(-community)?)/)', ], setupFiles: [require.resolve('./jest/setup.js')], - testEnvironment: 'node', + testEnvironment: require.resolve('./jest/react-native-env.js'), }; diff --git a/jest/react-native-env.js b/jest/react-native-env.js new file mode 100644 index 00000000000000..f85d82e4e5c425 --- /dev/null +++ b/jest/react-native-env.js @@ -0,0 +1,16 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + + 'use strict'; + +const NodeEnv = require('jest-environment-node').TestEnvironment; + +module.exports = class ReactNativeEnv extends NodeEnv { + // this is where we'll add our custom logic +}; From 399651ad62f8734c26543d8d79146f173d12927f Mon Sep 17 00:00:00 2001 From: Lorenzo Sciandra Date: Thu, 13 Oct 2022 17:48:14 +0100 Subject: [PATCH 2/3] prettier --- jest/react-native-env.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest/react-native-env.js b/jest/react-native-env.js index f85d82e4e5c425..b45ac255d9c202 100644 --- a/jest/react-native-env.js +++ b/jest/react-native-env.js @@ -7,7 +7,7 @@ * @format */ - 'use strict'; +'use strict'; const NodeEnv = require('jest-environment-node').TestEnvironment; From 7026c1445fe1a5ba1e9a678228b8e9abfae1734e Mon Sep 17 00:00:00 2001 From: Lorenzo Sciandra Date: Fri, 14 Oct 2022 11:13:41 +0100 Subject: [PATCH 3/3] adding to the deps in root package.json --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index ea795ea6623df1..db213015ee403f 100644 --- a/package.json +++ b/package.json @@ -120,6 +120,7 @@ "base64-js": "^1.1.2", "event-target-shim": "^5.0.1", "invariant": "^2.2.4", + "jest-environment-node": "^29.0.3", "jsc-android": "^250230.2.1", "memoize-one": "^5.0.0", "metro-react-native-babel-transformer": "0.72.3",