Jest-resolve broken: getMockModule throws an error
See original GitHub issue💥 Regression Report
A clear and concise description of what the regression is.
Last working version
Worked up to version: 26.6.1
Stopped working in version: 26.6.2
To Reproduce
Steps to reproduce the behavior:
jest.config.js
'moduleNameMapper': {
'^ui(.*)': '<rootDir>/ui$1',
}
import xSelector from "selectors/ui.selector.js"
throw error
Configuration error:
Could not locate module ui.selector mapped as:
/Users/xxx/Projects/xxx/src/ui$1.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/^ui(.*)/": "/Users/xxx/Projects/xxx/src/ui$1"
},
"resolver": undefined
}
Expected behavior
not throwed
Link to repl or repo (highly encouraged)
Run npx envinfo --preset jest
System:
OS: macOS 10.15.2
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Binaries:
Node: 13.6.0 - ~/.nvm/versions/node/v13.6.0/bin/node
Yarn: 1.21.1 - ~/.yarn/bin/yarn
npm: 6.13.4 - ~/.nvm/versions/node/v13.6.0/bin/npm
npmPackages:
jest: 26.1.0 => 26.1.0
I can fix the regex, but the problem persists for others
This error here https://github.com/facebook/jest/blob/master/packages/jest-resolve-dependencies/src/index.ts#L78
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
jest --watch hangs silently if moduleNameMapper cannot ...
getMockModule inside the jest-resolve package and noticed nothing was ... console.error(error) before every line that says throw error ?
Read more >Successfully Throwing Async Errors with the Jest Testing Library
Today, I'll discuss how to successfully test expected errors are thrown with the popular JavaScript testing library Jest, so you can rest ...
Read more >How to properly make mock throw an error in Jest?
I have 2 tests (each one in a separate test suit) where I mock one function (namely, Meteor's callMethod ) that is used...
Read more >eslint-config-typescript for vue-cli | Code Analyzer library - kandi
Implement eslint-config-typescript with how-to, Q&A, fixes, code snippets. kandi ratings - Low support, No Bugs, No Vulnerabilities.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @FrontendMMA! I had to change some stuff to make it work and understand where the regression was, I opened a PR: https://github.com/FrontendMMA/jest-resolve--bug-example/pull/1
@brapifra would you be able to take a look at this? If you look at my branch it can be reproduced by removing the
resolutions
, runningyarn
and then follow the steps @FrontendMMA lists out in the comment above.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.