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

Error: Failed to get mock metadata on npm test: Why this happen? #491

Closed
joowh85 opened this issue Mar 10, 2016 · 11 comments
Closed

Error: Failed to get mock metadata on npm test: Why this happen? #491

joowh85 opened this issue Mar 10, 2016 · 11 comments

Comments

@joowh85
Copy link

joowh85 commented Mar 10, 2016

When I try

npm test

always fail with the errors.
What should I do?

My OS is Windows 10.

> eslint src && jest

Using Jest CLI v0.9.0, jasmine2, babel-jest
 FAIL  components\App\__tests__\App-test.js
● Runtime Error
Error: Failed to get mock metadata: C:\Users\sangw\Documents\Work\jimiarts-web\node_modules\core-js\library\modules\_global.js

See: http://facebook.github.io/jest/docs/manual-mocks.html#content
    at Loader._generateMock (C:\Users\sangw\Documents\Work\jimiarts-web\node_modules\jest-cli\src\HasteModuleLoader\HasteModuleLoader.js:355:15)
    at Loader.requireMock (C:\Users\sangw\Documents\Work\jimiarts-web\node_modules\jest-cli\src\HasteModuleLoader\HasteModuleLoader.js:215:45)
    at Loader.requireModuleOrMock (C:\Users\sangw\Documents\Work\jimiarts-web\node_modules\jest-cli\src\HasteModuleLoader\HasteModuleLoader.js:226:19)
    at Object.<anonymous> (C:\Users\sangw\Documents\Work\jimiarts-web\node_modules\core-js\library\modules\_shared.js:1:133)
    at Loader._execModule (C:\Users\sangw\Documents\Work\jimiarts-web\node_modules\jest-cli\src\HasteModuleLoader\HasteModuleLoader.js:310:17)
    at Loader.requireModule (C:\Users\sangw\Documents\Work\jimiarts-web\node_modules\jest-cli\src\HasteModuleLoader\HasteModuleLoader.js:155:14)
    at Loader._generateMock (C:\Users\sangw\Documents\Work\jimiarts-web\node_modules\jest-cli\src\HasteModuleLoader\HasteModuleLoader.js:347:34)
    at Loader.requireMock (C:\Users\sangw\Documents\Work\jimiarts-web\node_modules\jest-cli\src\HasteModuleLoader\HasteModuleLoader.js:215:45)
    at Loader.requireModuleOrMock (C:\Users\sangw\Documents\Work\jimiarts-web\node_modules\jest-cli\src\HasteModuleLoader\HasteModuleLoader.js:226:19)
    at Object.<anonymous> (C:\Users\sangw\Documents\Work\jimiarts-web\node_modules\core-js\library\modules\_shared-key.js:1:133)
npm ERR! Test failed.  See above for more details.

@joowh85 joowh85 changed the title Error: Failed to get mock metadata on npm test Error: Failed to get mock metadata on npm test: Why this happen? Mar 12, 2016
@koistya
Copy link
Member

koistya commented Mar 12, 2016

I'm unable to reproduce it in the latest version of RSK, on Windows. Have you altered the test, or it matches to the one from this repo? See jestjs/jest#678.

@Stupidism
Copy link

Got this error, too.
Ubuntu 14, node 5.6.0.
I got this error in my project first(node 4, npm 3).
Then I reproduce it by following your start guide, git clone ... and npm install with node 5.6.0

Using Jest CLI v0.9.2, jasmine2, babel-jest
 FAIL  components/App/__tests__/App-test.js
● Runtime Error

Error: Failed to get mock metadata: /home/stupid/Desktop/MyApp/node_modules/core-js/library/modules/_global.js

See: http://facebook.github.io/jest/docs/manual-mocks.html#content
    at Object.<anonymous> (/home/stupid/Desktop/MyApp/node_modules/core-js/library/modules/_shared.js:1:133)
    at Object.<anonymous> (/home/stupid/Desktop/MyApp/node_modules/core-js/library/modules/_shared-key.js:1:133)
npm ERR! Test failed.  See above for more details.

@Stupidism
Copy link

This only works for me, by far!!!

Finally, I find a solution, although I can't figure out why.

Just delete the whole project and clone from your own repo, not clone a singile-branch from react-starter-kit as the start-guide said. npm test should work.

Of cource, normal process is

  • Do as start-guide said.
  • Push to your own repo origin master.
  • Delete the whole project.
  • Clone from your own repo and npm install
  • Run npm test

Only remove node_modules and renpm install doesn't do the trick. Maybe something wrong with git itself.

@JeffreyATW
Copy link

I'm having the same issue. I even tried changing my App.js file back to the original one here, and I tried re-cloning my repo, but nothing's working.

@Bogdaan
Copy link

Bogdaan commented Mar 17, 2016

@stupidisum ) sory, but this is not solution
@JeffreyATW install dev dependency:

npm install --dev

@JeffreyATW
Copy link

That didn't do anything. My version of npm says that --dev is deprecated, and I'm pretty sure it installs devDependencies automatically.

Node: 5.9.0, npm: 3.7.3

@JeffreyATW
Copy link

Update: I tried updating jest-cli to 0.9.3, which supposedly contains some related fixes, but it didn't fix anything.

@JeffreyATW
Copy link

Adding core-js to unmockedModulePathPatterns in package.json results in a separate (possibly unrelated) message:

 FAIL  components/App/__tests__/App-test.js
● Runtime Error
TypeError: Cannot read property 'displayName' of undefined
    at getDisplayName (eval at runSourceText ([...]/node_modules/jest-cli/src/environments/JSDOMEnvironment.js:37:3), <anonymous>:53:26)

@JeffreyATW
Copy link

Yep, it looks like that other problem is mine. I'll send a PR to include "core-js" to unmockedModulePathPatterns.

@everdimension
Copy link

Same problem on mac.

Unmocking core-js makes the test script throw another error:

● Runtime Error
TypeError: (0 , _useQueries2.default)(...) is not a function
    at Object.<anonymous> (/Users/rnd/web/react-project/src/core/Location.js:14:175)
    at Object.<anonymous> (/Users/rnd/web/react-project/src/components/Link/Link.js:11:41)
    at Object.<anonymous> (/Users/rnd/web/react-project/src/components/Header/Header.js:13:37)
    at Object.<anonymous> (/Users/rnd/web/react-project/src/components/App/App.js:13:39)
    at Object.<anonymous> (/Users/rnd/web/react-project/src/components/App/__tests__/App-test.js:5:36)

@ulani
Copy link
Member

ulani commented May 27, 2021

@joowh85 thank you very much for crating this issue! Unfortunately, we have close it due to inactivity. Feel free to re-open it or join our Discord channel for discussion.

NOTE: The main branch has been updated with React Starter Kit v2, using JAM-style architecture.

@ulani ulani closed this as completed May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants