Skip to content

Commit

Permalink
jest: Expand coverage to include Android-only codepaths.
Browse files Browse the repository at this point in the history
This means that our Jest tests will take ~twice as long as they took
before. We'll soon add an option to `tools/test` to run the Jest
tests for just one platform, which we can use locally to speed
things up, just without getting as much coverage as we'd otherwise
get. See discussion at
  https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/.60jest-expo.2Fios.60.20and.20.60jest-expo.2Fandroid.60/near/1169139.
  • Loading branch information
chrisbobbe authored and gnprice committed May 3, 2021
1 parent 2a53ad6 commit 80a68be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 4 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,8 @@ const common = {

module.exports = {
// See https://github.com/expo/expo/blob/master/packages/jest-expo/README.md#platforms.
projects: [{ ...common, displayName: 'ios', preset: 'jest-expo/ios' }],
projects: [
{ ...common, displayName: 'ios', preset: 'jest-expo/ios' },
{ ...common, displayName: 'android', preset: 'jest-expo/android' },
],
};
11 changes: 4 additions & 7 deletions jest/jestSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,13 @@ polyfillGlobal('URLSearchParams', () => URLSearchParams);
// [1] https://github.com/facebook/react-native/issues/26579#issuecomment-535244001
// [2] https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/.23M3781.20RN.20v0.2E61.20upgrade/near/931219
jest.mock('react-native', () => {
ReactNative.NativeModules.ZLPConstants =
// Currently only available on iOS. We don't bother
// conditionalizing on the platform here; if we want to mock
// Platform.OS, we'll likely want to do so per-test. In that
// scenario, we'll need to figure out how to recompute this mock
// with Platform.OS set as desired.
{
if (ReactNative.Platform.OS === 'ios') {
ReactNative.NativeModules.ZLPConstants = {
resourceURL:
'file:///private/var/containers/Bundle/Application/4DCD4D2B-F745-4C70-AD74-8E5F690CF593/ZulipMobile.app/',
};
}

return ReactNative;
});

Expand Down

0 comments on commit 80a68be

Please sign in to comment.