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

require.requireActual no longer seems to use moduleNameMapper when resolving path #7981

Closed
stevoland opened this issue Feb 25, 2019 · 2 comments · Fixed by #8210
Closed

require.requireActual no longer seems to use moduleNameMapper when resolving path #7981

stevoland opened this issue Feb 25, 2019 · 2 comments · Fixed by #8210

Comments

@stevoland
Copy link

💥 Regression Report

require.requireActual no longer seems to use moduleNameMapper when resolving path. Seems to be caused by this change https://github.com/facebook/jest/pull/7404/files#diff-5b4dfdf819aec7c512e60abc8ed754b5R850

Last working version

Worked up to version: 23.6.0

Stopped working in version: 24.0.0

To Reproduce

Add any moduleNameMapper config, EG:

{
  "moduleNameMapper": {
    "/lib$": "<rootDir>/mapped-lib.js"
  }
}

Create mapped module at destination path

// mapped-lib.js
module.exports = {}

require.requireActual the source path

// add.test.js
require.requireActual('./lib')

Expected behavior

Mapped module should be loaded without error

Link to repl or repo (highly encouraged)

Working repl in Jest 22.1.2
https://repl.it/repls/UnusedBoldNlp

In Jest 24.1.0 this errors:

● Test suite failed to run

    Cannot find module './lib' from 'add.test.js'

Run npx envinfo --preset jest

Paste the results here:

System:
    OS: macOS 10.14
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
    Yarn: 1.12.3 - ~/.nvm/versions/node/v10.13.0/bin/yarn
    npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
  npmPackages:
    jest: 24 => 24.1.0
@SimenB
Copy link
Member

SimenB commented Mar 4, 2019

Wanna send a PR fixing it?

@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 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants