Skip to content

Commit

Permalink
jest: Back out jest-expo preset, for now.
Browse files Browse the repository at this point in the history
A reversion of e40c020 and 62621ef. Unfortunately, Jest 26 (the
latest), which we'll take in an upcoming commit, doesn't support
`jest-expo` at 37 [1].

We can't go past 37 (e.g., to 38.0.2, the latest) until we upgrade
to React Native v0.62 (that's zulip#3782). That's because jest-expo's
"react" peer dependency was bumped from ~16.9.0 to ~16.11.0 in
expo/expo#8310 [2], and we must do that React upgrade atomically
with our RN upgrade. The "react-native" peer dependency wasn't
touched; it remained at "*". So, I'm left unsure whether it was
intentional to drop support for RN v0.61 [3].

Ah, well. As I said in e40c020:

"""
If `jest-expo` turns out to be buggy, or the dependency requirements
get even more tangled or burdensome, we should feel free to abandon
this effort; it's not terrible to have to add boring mocks.
"""

We may consider adding it back in as a followup to zulip#3782.

Run our usual `yarn yarn-deduplicate && yarn`, as prompted by
`tools/test deps`.

[1] We get errors about jest-expo using `require.requireActual`,
    which was removed in jestjs/jest#9854, out in v26.0.0-alpha.0.
[2] expo/expo@a4cabf30a#diff-4a85ebd1069aff25ee2e5f2b004281ccR33
[3] See react-native-webview/react-native-webview#1445.
  • Loading branch information
chrisbobbe committed Aug 12, 2020
1 parent e3e8d9a commit 235c487
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 343 deletions.
3 changes: 1 addition & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// These will be used as regexp fragments.
const transformModulesWhitelist = [
'expo-apple-authentication',
'expo-application',
'react-native',
// @rnc/async-storage itself is precompiled, but its mock-helper is not
'@react-native-community/async-storage',
Expand All @@ -25,7 +24,7 @@ const transformModulesWhitelist = [
const transformIgnorePattern = `node_modules/(?!${transformModulesWhitelist.join('|')})`;

module.exports = {
preset: 'jest-expo',
preset: 'react-native',

// Finding and transforming source code.

Expand Down
11 changes: 11 additions & 0 deletions jest/jestSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ jest.mock('react-native-simple-toast', () => ({
showWithGravity: jest.fn(),
}));

jest.mock('expo-application', () => ({
nativeApplicationVersion: '26.23.146',
}));

jest.mock('react-native-device-info', () => ({
getSystemName: jest.fn().mockReturnValue('ios'),
getSystemVersion: jest.fn().mockReturnValue('13.3.1'),
Expand All @@ -89,3 +93,10 @@ jest.mock('react-native-image-picker', () => ({
launchCamera: jest.fn(),
launchImageLibrary: jest.fn(),
}));

jest.mock('expo-apple-authentication', () => ({
AppleAuthenticationButton: jest.fn(),
isAvailableAsync: jest.fn(),
signInAsync: jest.fn(),
// etc. (incomplete)
}));
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@
"jest-cli": "^24.9.0",
"jest-environment-jsdom": "^24.9.0",
"jest-environment-jsdom-global": "^1.2.0",
"jest-expo": "^37.0.0",
"jest-extended": "^0.11.2",
"jetifier": "^1.6.5",
"lolex": "^5.1.1",
Expand All @@ -123,9 +122,7 @@
"prettier-eslint": "^9.0.0",
"prettier-eslint-cli": "^5.0.0",
"prop-types": "^15.7.2",
"react-dom": "16.9.0",
"react-native-cli": "^2.0.1",
"react-native-web": "^0.13.3",
"redux-mock-store": "^1.5.1",
"rollup": "^1.23.1",
"rollup-plugin-babel": "^4.3.3",
Expand Down
Loading

0 comments on commit 235c487

Please sign in to comment.