Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cannot read config when upgrading jest-expo to 41.0.1 #13577

Closed
hyochan opened this issue Jul 11, 2021 · 9 comments
Closed

Test cannot read config when upgrading jest-expo to 41.0.1 #13577

hyochan opened this issue Jul 11, 2021 · 9 comments
Assignees
Labels
Jest with Expo Pertains to using Jest with an Expo project. pending closure awaiting final response before closing

Comments

@hyochan
Copy link
Contributor

hyochan commented Jul 11, 2021

Summary

When upgrading jest-expo from 42.0.0 to 42.0.1, it suddenly can't read config at app.config.ts so the tests fail.

ConfigError: Failed to read config at: /home/hyo/Github/dooboolab/dooboo-expo/app.config.ts

Managed or bare workflow? If you have ios/ or android/ directories in your project, the answer is bare!

managed

What platform(s) does this occur on?

Android, iOS, Web

SDK Version (managed workflow only)

42.0.1

Environment

  Expo CLI 4.7.3 environment info:
    System:
      OS: Linux 5.8 Ubuntu 20.10 (Groovy Gorilla)
      Shell: 5.8 - /usr/bin/zsh
    Binaries:
      Node: 15.14.0 - ~/.nvm/versions/node/v15.14.0/bin/node
      Yarn: 1.22.10 - ~/.nvm/versions/node/v15.14.0/bin/yarn
      npm: 7.7.6 - ~/.nvm/versions/node/v15.14.0/bin/npm
      Watchman: 4.9.0 - /usr/bin/watchman
    npmPackages:
      @expo/webpack-config: ^0.12.82 => 0.12.82 
      expo: ^42.0.1 => 42.0.1 
      react: 16.13.1 => 16.13.1 
      react-dom: 16.13.1 => 16.13.1 
      react-native: https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz => 0.63.2 
      react-native-web: ~0.13.12 => 0.13.18 
    Expo Workflow: managed

Reproducible demo or steps to reproduce from a blank project

I am managing expo version updates in https://github.com/dooboolab/dooboo-expo.

  1. Clone the repository

    git clone https://github.com/dooboolab/dooboo-expo.git
    
  2. Check out the branch

    git checkout release/42
    
  3. Install packages

    yarn
    
  4. Run tests

    yarn test
    

    It will succeed first time.

  5. Upgrade jest-expo from 42.0.0 => 42.0.1 and run test again.

    yarn test
    

Then tests breaks with below error.

image

@hyochan hyochan added the needs validation Issue needs to be validated label Jul 11, 2021
@hyochan hyochan changed the title Test Test cannot read config when upgrading jest-expo to 41.0.1 Jul 11, 2021
@byCedric
Copy link
Member

Hi @hyochan, thanks for writing in. If you upgraded to Expo SDK 42, you also have to use jest-expo@42.x.x. Please upgrade that dependency and try running it again.

@byCedric byCedric added Jest with Expo Pertains to using Jest with an Expo project. pending closure awaiting final response before closing and removed needs validation Issue needs to be validated labels Jul 12, 2021
@hyochan
Copy link
Contributor Author

hyochan commented Jul 12, 2021

@byCedric Opps I am really sorry. I mentioned the wrong version. Yes! I've tried with expo sdk 42 and when I upgrade expo to 42.0.1 and jest-expo to 42.0.1, the problem occurred.

You can test the reproducible demo I've mentioned in the issue. This works in jest-expo: 42.0.0 but not in 42.0.1.

@ludu12
Copy link

ludu12 commented Jul 12, 2021

Hi I'm experiencing this same issue with versions:

    "expo": "42.0.0",
    "jest-expo": "42.0.1",

@brentvatne
Copy link
Member

this seems related to this diff: #7557

@EvanBacon plans to investigate. you can use jest-expo@42.0.0 for now if this is a problem in your app.

@EvanBacon
Copy link
Contributor

Screen Shot 2021-07-12 at 1 11 24 PM

Can't repro, maybe try a clean yarn install.

@hyochan
Copy link
Contributor Author

hyochan commented Jul 13, 2021

Screen Shot 2021-07-12 at 1 11 24 PM

Can't repro, maybe try a clean yarn install.

Hi @EvanBacon Thank you for trying it. I think you have not yarn add jest-expo and updated jest-expo to 42.0.1,
Currently it is "jest-expo": "^42.0.0", and I am not upgrading it because the CI fails after that.

In case if this is a problem with the node version, I'll specify the versions below.

node: v15.14.0
yarn: 1.22.10

The results are below.
image
image

@EvanBacon
Copy link
Contributor

Can repro now, adding json to the jest.config.js fixed the issue:

  moduleFileExtensions: ['js', 'ts', 'tsx', 'svg', 'png', 'json'],

I'll open a PR to improve the error message, it should surface the babel/jest error:

 [BABEL] /Users/evanbacon/Documents/GitHub/lab/dooboo-expo/app.config.ts: Cannot find module './modules-by-versions' from 'get-modules-list-for-target-version.js'

    Require stack:
      node_modules/core-js-compat/get-modules-list-for-target-version.js
      node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js
      node_modules/@babel/preset-env/lib/index.js
      node_modules/@expo/config/build/getBabelPreset.js
      node_modules/@expo/config/build/evalConfig.js
      node_modules/@expo/config/build/getConfig.js
      node_modules/@expo/config/build/Config.js
      node_modules/@expo/config/build/index.js
      node_modules/jest-expo/src/preset/createMockConstants.js
      node_modules/jest-expo/src/preset/setup.js


    However, Jest was able to find:
    	'./modules-by-versions.json'

    You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['js', 'ts', 'tsx', 'svg', 'png'].

    See https://jestjs.io/docs/en/configuration#modulefileextensions-arraystring (While processing: "base$0")

hyochan added a commit to dooboolab-community/dooboo-expo that referenced this issue Jul 14, 2021
@hyochan
Copy link
Contributor Author

hyochan commented Jul 14, 2021

@EvanBacon Yeah it works perfectly! Providing error message is great idea 💯

@EvanBacon
Copy link
Contributor

Thanks for raising, the issue! Should be a pretty nice improvement in expo/config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Jest with Expo Pertains to using Jest with an Expo project. pending closure awaiting final response before closing
Projects
None yet
Development

No branches or pull requests

5 participants