Skip to content

Commit

Permalink
jest: Back out jest-expo preset, again.
Browse files Browse the repository at this point in the history
A reversion of c4fca9d, continuing a pattern of adding and
removing `jest-expo` as we learn new things:

62621ef jest: Add `jest-expo` preset, to be used in the next commit.
347aa96 jest: Back out `jest-expo` preset, for now.
c4fca9d jest: Add and use `jest-expo` preset, again.

This time, we learn that `jest-expo` in its current latest version
brings in Jest 25, and Jest 25 ends up being used to run our tests
instead of Jest 26, which we took in our own direct dependencies, in
fb23341.

Without backing out `jest-expo`, the next few commits (where we
start using Jest's fake timers) would see symptoms like those we saw
while working on fb23341, before we realized it was necessary to
add @jest/source-map. The new "modern" fake-timer implementation
isn't available, and we get no friendly message from Jest to tell us
about it [1].

When `jest-expo` comes out with a version that has Jest 26 in its
dependencies, we can presumably take that version.

[1] In Jest 25, calling `jest.useFakeTimers('modern')` is error-free
    but has the same effect as `jest.useFakeTimers()`, which, in Jest
    26, is a way to spell `jest.useFakeTimers('legacy')`.
  • Loading branch information
chrisbobbe committed Oct 27, 2020
1 parent a7f4a1a commit cfe3314
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 1,734 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public List<Package> getPackageList() {
new expo.modules.filesystem.FileSystemPackage(),
new expo.modules.imageloader.ImageLoaderPackage(),
new expo.modules.permissions.PermissionsPackage(),
new expo.modules.screenorientation.ScreenOrientationPackage(),
new expo.modules.splashscreen.SplashScreenPackage()
new expo.modules.screenorientation.ScreenOrientationPackage()
);
}
}
7 changes: 0 additions & 7 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ PODS:
- EXScreenOrientation (1.0.0):
- React-Core
- UMCore
- EXSplashScreen (0.5.0):
- React
- UMCore
- FBLazyVector (0.62.2)
- FBReactNativeSpec (0.62.2):
- Folly (= 2018.10.22.00)
Expand Down Expand Up @@ -405,7 +402,6 @@ DEPENDENCIES:
- EXImageLoader (from `../node_modules/expo-image-loader/ios`)
- EXPermissions (from `../node_modules/expo-permissions/ios`)
- EXScreenOrientation (from `../node_modules/expo-screen-orientation/ios`)
- EXSplashScreen (from `../node_modules/expo-splash-screen/ios`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- FBReactNativeSpec (from `../node_modules/react-native/Libraries/FBReactNativeSpec`)
- Flipper (~> 0.39.0)
Expand Down Expand Up @@ -520,8 +516,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/expo-permissions/ios"
EXScreenOrientation:
:path: "../node_modules/expo-screen-orientation/ios"
EXSplashScreen:
:path: "../node_modules/expo-splash-screen/ios"
FBLazyVector:
:path: "../node_modules/react-native/Libraries/FBLazyVector"
FBReactNativeSpec:
Expand Down Expand Up @@ -649,7 +643,6 @@ SPEC CHECKSUMS:
EXImageLoader: 02ca02c9cd5cc8a97b423207a73a791e0a86bea5
EXPermissions: 80ac3acbdb145930079810fe5b08c022b3428aa8
EXScreenOrientation: 44d3cd3a99a86b9cb681e742697bc2c057d7fbd2
EXSplashScreen: 9423d258b71afa5bf128a83dcb57b636d9900a74
FBLazyVector: 4aab18c93cd9546e4bfed752b4084585eca8b245
FBReactNativeSpec: 5465d51ccfeecb7faa12f9ae0024f2044ce4044e
Flipper: bee8d5809012d1b6affa747fb756567ecd8c7c0b
Expand Down
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 @@ -85,6 +85,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 @@ -101,3 +105,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)
}));
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"expo-apple-authentication": "^2.1.1",
"expo-application": "^2.1.1",
"expo-screen-orientation": "^1.0.0",
"expo-splash-screen": "^0.5.0",
"immutable": "^4.0.0-rc.12",
"json-stringify-safe": "^5.0.1",
"katex": "^0.11.1",
Expand Down Expand Up @@ -125,7 +124,6 @@
"jest-cli": "^26.4.1",
"jest-environment-jsdom": "^26.3.0",
"jest-environment-jsdom-global": "^2.0.4",
"jest-expo": "^38.0.2",
"jest-extended": "^0.11.5",
"jetifier": "^1.6.5",
"lolex": "^5.1.1",
Expand All @@ -134,9 +132,7 @@
"prettier-eslint": "^11.0.0",
"prettier-eslint-cli": "^5.0.0",
"prop-types": "^15.7.2",
"react-dom": "16.11.0",
"react-native-cli": "^2.0.1",
"react-native-web": "^0.13.3",
"redux-mock-store": "^1.5.1",
"rollup": "^2.26.5",
"typescript": "~3.8.3",
Expand Down
Loading

0 comments on commit cfe3314

Please sign in to comment.