Jest Constants.manifest.extra undefined

After upgrading from 45 to 46 Constants.manifest.extra is now undefined only when running my Jest tests. Does anyone have any idea as to why this would break between versions. I can’t see anything mentioned in the upgrade notes.

Hey @markybry,

Are you using [jest-expo] (expo/packages/jest-expo at main · expo/expo · GitHub)? If you can, please share a minimal reproducible example so that I can clone it on my end and see what could be the issue.

That’s right I am using jest-expo. Here is a link to a minimal reproduction of the issue.

1 Like

Thanks for sharing it. Let me try and I’ll get back to you.

1 Like

The best i could do to get it working was to mock expo-constants. I’m not sure really what I should be doing going forward though. I am confused around when to use expo-constants , expo-updates, manifest and manifest2 . Also it is unclear which packages support what seems to be the new method. Auth session has a load of code to handle legacy config which looks quite horrible. I mostly do behaviour driven dev and my tests are therefore are low on mocking and are focused on testing the whole feature at the boundaries of any given context.

I’m not all sure what the expo team are trying to achieve with the expo-constants changes.

jest.mock('expo-constants', () => {

  return {
    "name": "eMar",
    ExecutionEnvironment: "standalone",
    expoConfig: {
      currentFullName: '@ourUser/ourAppName',
      originalFullName: '@ourUser/ourAppName',
    },
    manifest: {
      version: '1.0.0',
      extra: {
        configChannel: "development",
      }

    }
  };
})

Hi @markybry,

Sorry for the late reply. Since you are trying to read an environment variable using expo-constants please see our documentation here on that: Environment variables in Expo - Expo Documentation

With SDK 46, one notable change was to move from Constants.manifest.extra to Constants.expoConfig.extra.

With the latest and newer SDKs, we are trying to make the process of reading env variables using a unified property (expoConfig). Apologies for any inconvenience caused and I understand your frustration around this.

Can you please be more explicit about your feedback earlier on the “packages support” or point me towards any specific package to understand how can we make resources such as documentation better or what is lacking?

1 Like

I have moved over to expoConfig now. However That didn’t resolve the config issue running from Jest. I am happy to carry on mocking the config to configure the context for the tests. It seems reasonable. My issue was with AuthSession when running my integration tests.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.