Skip to content

Commit

Permalink
jest: Use jest-expo/ios preset.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
chrisbobbe authored and gnprice committed May 3, 2021
1 parent cf6f725 commit 2a53ad6
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions jest.config.js
Expand Up @@ -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$'],
Expand All @@ -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' }],
};

0 comments on commit 2a53ad6

Please sign in to comment.