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 [1] 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` (i.e., with Jest 25 still used to
run our tests), 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 [2].

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

[1] jest-expo@41.0.0-beta.0; see
    https://github.com/expo/expo/blob/84c241afc/packages/jest-expo/package.json#L36

[2] In Jest 25, a call to `jest.useFakeTimers('modern')` doesn't
    throw any errors, but the 'modern' is ignored and the legacy
    implementation is used.
  • Loading branch information
chrisbobbe committed Apr 13, 2021
1 parent 0d43ee3 commit 88d6f50
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 1,751 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.63.4)
- FBReactNativeSpec (0.63.4):
- Folly (= 2020.01.13.00)
Expand Down Expand Up @@ -408,7 +405,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.54.0)
Expand Down Expand Up @@ -522,8 +518,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 @@ -651,7 +645,6 @@ SPEC CHECKSUMS:
EXImageLoader: 02ca02c9cd5cc8a97b423207a73a791e0a86bea5
EXPermissions: 80ac3acbdb145930079810fe5b08c022b3428aa8
EXScreenOrientation: 44d3cd3a99a86b9cb681e742697bc2c057d7fbd2
EXSplashScreen: 9423d258b71afa5bf128a83dcb57b636d9900a74
FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e
FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e
Flipper: be611d4b742d8c87fbae2ca5f44603a02539e365
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 @@ -100,6 +100,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 @@ -117,6 +121,13 @@ jest.mock('react-native-image-picker', () => ({
launchImageLibrary: jest.fn(),
}));

jest.mock('expo-apple-authentication', () => ({
AppleAuthenticationButton: jest.fn(),
isAvailableAsync: jest.fn(),
signInAsync: jest.fn(),
// etc. (incomplete)
}));

// Set up our `logging` module with mocks, which tests can use as desired.
//
// This global version just passes the calls right through to the real
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,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",
"invariant": "^2.2.4",
"json-stringify-safe": "^5.0.1",
Expand Down Expand Up @@ -123,7 +122,6 @@
"jest-cli": "^26.4.1",
"jest-environment-jsdom": "^26.3.0",
"jest-environment-jsdom-global": "^2.0.4",
"jest-expo": "^40.0.1",
"jest-extended": "^0.11.5",
"jetifier": "^1.6.5",
"lolex": "^5.1.1",
Expand All @@ -132,9 +130,7 @@
"prettier-eslint": "^12.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

0 comments on commit 88d6f50

Please sign in to comment.