From 2a53ad6a448df7d16a22fb98450ee2dbde6ba22f Mon Sep 17 00:00:00 2001 From: Chris Bobbe Date: Tue, 27 Apr 2021 09:01:27 -0400 Subject: [PATCH] jest: Use `jest-expo/ios` preset. When we've used the `jest-expo` preset or the `react-native` preset, the tests get run "in the standard React Native environment (iOS)" [1]. The key piece of this is that they run with `Platform.OS` mocked to 'ios'. We're about to add another "project" to test Android codepaths with `jest-expo/android`. First, though, swap out the old `jest-expo` preset for this more explicit one so we don't have to think about three presets. [1] https://github.com/expo/expo/blob/master/packages/jest-expo/README.md#platforms --- jest.config.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jest.config.js b/jest.config.js index b8834e9e9ed..b65358bc57c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -24,9 +24,7 @@ const transformModulesWhitelist = [ // (This value is correctly a string, not a RegExp.) const transformIgnorePattern = `node_modules/(?!${transformModulesWhitelist.join('|')})`; -module.exports = { - preset: 'jest-expo', - +const common = { // Finding and transforming source code. testPathIgnorePatterns: ['/node_modules/', '/src/__tests__/lib/', '-testlib.js$'], @@ -49,3 +47,8 @@ module.exports = { setupFiles: ['./jest/globalFetch.js', './node_modules/react-native-gesture-handler/jestSetup.js'], setupFilesAfterEnv: ['./jest/jestSetup.js', 'jest-extended'], }; + +module.exports = { + // See https://github.com/expo/expo/blob/master/packages/jest-expo/README.md#platforms. + projects: [{ ...common, displayName: 'ios', preset: 'jest-expo/ios' }], +};