expo: [JEST-EXPO] Error on pathResolve

๐Ÿ› Bug Report

Summary of Issue (just a few sentences)

I am using Jest-expo 38 for my tests and since my upgrade from 37 to 38, I got this error below.

Environment - output of expo diagnostics & the platform(s) youโ€™re targeting

$ expo diagnostics

  Expo CLI 3.21.12 environment info:
    System:
      OS: Linux 5.6 Manjaro Linux
      Shell: 5.8 - /usr/bin/zsh
    Binaries:
      Node: 14.3.0 - /usr/bin/node
      Yarn: 1.22.4 - /usr/bin/yarn
      npm: 6.14.5 - /usr/bin/npm
    npmPackages:
      expo: ^38.0.0 => 38.0.3
      react: 16.11.0 => 16.11.0
      react-dom: 16.11.0 => 16.11.0
      react-native: https://github.com/expo/react-native/archive/sdk-38.0.0.tar.gz => 0.62.2
      react-native-web: ~0.11.7 => 0.11.7
    npmGlobalPackages:
      expo-cli: 3.21.12
> @ test /home/me/code
> jest

internal/validators.js:121
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object
    at validateString (internal/validators.js:121:11)
    at Object.resolve (path.js:980:7)
    at Object.<anonymous> (/home/me/code/node_modules/jest-expo/bin/jest.js:20:30)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'ERR_INVALID_ARG_TYPE'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ test: `jest`
npm ERR! Exit status 1

I fixed this issue by editing node_modules/jest-expo/bin/jest.js at line 20 by:

const jestProgramPath = path.resolve(jestPackagePath, jestPackageJson.bin.jest);

What do you think

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 18 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Was this fixed? I still have this issue, and it seems to be fixed after downgrading to jest-expo@37

I have exactly the same issue after installing jest-expo@38.0.0. By downgrading to jest-expo@37.0.0, tests now run as expected.

Thanks for the confirmation, thatโ€™s it then. I have no clue whatsoever why NPM decided bin: "some/string.js" is actually short for bin: { myapp: "some/string.js" }. But a PR to fix it is on itโ€™s way! ๐Ÿ˜„

Also happening on my CI after upgrading to SDK 38. Will be downgrading to jest-expo 37 for now and waiting for the merge and release to have it properly versioned. Thanks!

Downgrading from @38.0.2 to @37.0.0 solved my issue.

@byCedric I am also using NPM, which confirms your hypothesis.

So this is kinda weird, but I think you are using NPM right? If I do yarn add jest@25.5.4, I get the proper "bin": "./bin/jest.js". But if I do npm install jest@25.5.4 I get the object you mentioned @abmantis. I guess we need to add support for both to get this working properly.

I just upgraded to Expo 38.0.0 and having the same issue. Downgrading to jest-expo@37.0.0 does fix this issue, as stated.

This was caused by the following change: https://github.com/expo/expo/pull/7556/files#diff-68c0f5a3773234e2ed284864d5b4003bR20

Editing the jest bin wrapper and adding back jestPackageJson.bin.jest, fixes the issue.