question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 3 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SimenBcommented, Nov 2, 2020

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, running yarn and then follow the steps @FrontendMMA lists out in the comment above.

0reactions
github-actions[bot]commented, May 11, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found