Skip to content

Jest-resolve broken: getMockModule throws an error #10771

@FrontendMMA

Description

@FrontendMMA

💥 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions