Expo-Constants failing Jest Test using app.config.js

Please provide the following:

  1. SDK Version:42
  2. Platforms(Android/iOS/web/all): All
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

As stated in the title, I am in the process of switching our project to use app.config.js ready for us to take up EAS builds. The app runs fine with the change.

However, when I run a Jest test, the app is currently failing with the following error:

TypeError: Cannot read property ‘environment’ of undefined
4 | import { getSettingsObject } from ‘…/…/utils/helpers/SettingsHelper’
5 |
> 6 | const enableInExpoDevelopment = Constants.manifest.extra.environment !== ‘Development’

Here is a simple test which it is failing

import React from 'react';
import renderer from 'react-test-renderer';
import App from '../App';
describe('<App />', () => {
  it('has 1 child',  async () => {
    const tree = renderer.create(<App />).toJSON();
    expect(tree.children.length).toBe(1);
  });
});

Any ideas/explanations would be greatly appreciated

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