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

Bug: Jest 20 moduleNameMapper broken #3716

Closed
orangecms opened this issue Jun 2, 2017 · 2 comments
Closed

Bug: Jest 20 moduleNameMapper broken #3716

orangecms opened this issue Jun 2, 2017 · 2 comments

Comments

@orangecms
Copy link

Do you want to request a feature or report a bug?
bug

What is the current behavior?
Module name is not translated 😢

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

git clone https://github.com/orangecms/jest-meteor-demo/
cd jest-meteor-demo
yarn install && yarn test

works so far. Then:

git checkout jest-20
yarn install && yarn test

breaks with the error message:
Cannot find module 'meteor/mdg:validated-method' from 'fooMethods.spec.js'

What is the expected behavior?
Module name should be translated 🙃

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
I'm using Jest 19 and tried upgrading to 20 (see the repo for exact versions) - that broke it.
Node: 7.10.0
npm: v4.2.0
yarn: v0.24.5
OS: GNU/Linux

{
  "transform": {
    "^.+\\.jsx?$": "babel-jest"
  },
  "moduleFileExtensions": [
    "js",
    "jsx"
  ],
  "modulePaths": [
    "<rootDir>/node_modules/",
    "<rootDir>/node_modules/jest-meteor-stubs/lib/"
  ],
  "moduleNameMapper": {
    "^(.*):(.*)$": "$1_$2"
  },
  "unmockedModulePathPatterns": [
    "/^imports\\/.*\\.jsx?$/",
    "/^node_modules/"
  ]
}

I have seen other issues here around the mapper, but couldn't solve it with the suggestions there, including #3565 which could be somehow related. I'm not sure though.

@rogeliog
Copy link
Contributor

rogeliog commented Jun 7, 2017

Thanks for the great and simple repro case... I'm able to reproduce it.

Renaming .jestrc to jest.config.js and chaning the contents of it to use module.exports = {...} makes it work

module.exports = {
 // your same config here
};

@rogeliog rogeliog closed this as completed Jun 7, 2017
@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 May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants