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

"Module * in the testRunner option was not found" when using "resolver": "browser-resolve" #10297

Closed
elado opened this issue Jul 21, 2020 · 12 comments

Comments

@elado
Copy link
Contributor

elado commented Jul 21, 2020

πŸ› Bug Report

jest@26.1.0
browser-resolve@1.11.3

When setting "resolver": "browser-resolve", option, jest shows the following error:

● Validation Error:

  Module <PATH>/node_modules/jest-jasmine2/build/index.js in the testRunner option was not found.
         <rootDir> is: <PATH>

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

<PATH>/node_modules/jest-jasmine2/build/index.js does exist.

To Reproduce

package.json:

{
  "dependencies": {
    "browser-resolve": "^1.11.3",
    "jest": "^26.1.0"
  },
  "jest": {
    "resolver": "browser-resolve"
  }
}

test.test.js:

test("x", () => {});
yarn jest

Tried also installing jest-circus and adding:

"testRunner": "jest-circus/runner"

and I'm getting

Module jest-circus/runner in the testRunner option was not found.

I guess it's related to recent deprecation of browser: https://github.com/facebook/jest/pull/9943/files

When I use the deprecated browser field, I'm getting a deprecation warning, but tests pass:

● Deprecation Warning:

  Option "browser" has been deprecated. Please install "browser-resolve" and use the "resolver" option in Jest configuration as follows:
  {
    "resolver": "browser-resolve"
  }
  

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

Expected behavior

No errors.

Link to repl or repo (highly encouraged)

REPL: https://repl.it/repls/HumongousSpottedMp3

yarn jest

envinfo

npx: installed 1 in 1.274s

  System:
    OS: macOS 10.15.5
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
  Binaries:
    Node: 10.19.0 - /var/folders/97/d27nhr893s91_1shcp7x_qsh0000gp/T/fnm-shell-882191/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.6 - /var/folders/97/d27nhr893s91_1shcp7x_qsh0000gp/T/fnm-shell-882191/bin/npm
  npmPackages:
    jest: ^26.1.0 => 26.1.0 
@andsalves
Copy link

+1 Getting exactly the same issue.

@SeanHayes
Copy link

I ran npm install jest-circus --save-dev, it's not installed by default.

@timgivois
Copy link

timgivois commented Nov 12, 2020

I found that somehow, the testRunner path on my package.json was hardcoded with an absolut path (/Users/timgivois.....). I had to change it to

"testRunner": "<rootDir>/node_modules/jest-circus/runner.js",

And I had to install jest-circus, just like Sean said:

yarn add --dev jest-circus

@lukejagodzinski
Copy link

Did anyone solve it without installing jest-circus?

@amrtawfik160
Copy link

Try to remove node_modules and package-lock.json then run npm install or yarn << This solution worked for me

@deriegle
Copy link

I found that somehow, the testRunner path on my package.json was hardcoded with an absolut path (/Users/timgivois.....). I had to change it to

"testRunner": "<rootDir>/node_modules/jest-circus/runner.js",

And I had to install jest-circus, just like Sean said:

yarn add --dev jest-circus

I just recently created a new React app using create-react-app and when I ejected, it did this.

I had to change the Jest testRunner configuration from /Users/devinriegle/code/projectName/node_modules/jest-circus/runner.js to <rootDir>/node_modules/jest-circus/runner.js

@MohamedElGhandour
Copy link

I found that somehow, the testRunner path on my package.json was hardcoded with an absolut path (/Users/timgivois.....). I had to change it to

"testRunner": "<rootDir>/node_modules/jest-circus/runner.js",

And I had to install jest-circus, just like Sean said:

yarn add --dev jest-circus

thank you, it's working now

@muhammedgaygisiz
Copy link

I had the same issue (hardcoded path). I just did an eject, probably it was because of that.

@filipe-costa
Copy link

/node_modules/jest-circus/runner.js

I was having the exact same issue when using Docker, this fixed it.

Thanks!

@andyomat
Copy link

I had the same issue (hardcoded path). I just did an eject, probably it was because of that.

Same here, did an eject earlier which added the absolute path that broke everything.

@SimenB
Copy link
Member

SimenB commented Jan 20, 2022

Default export if browser-resolve is async, so you need a module in between (see docs).


Hard coded jest-circus is not related (but probably caused by ejecting CRA: facebook/create-react-app#9993)

@SimenB SimenB closed this as completed Jan 20, 2022
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests