Do you want to request a _feature_ or report a _bug_?
Bug.
What is the current behavior?
path.resolve ignores mocked process.cwd.
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.
Demo: https://repl.it/@borodean/jest-issue-process-cwd
What is the expected behavior?
path.resolve should resolve from the mocked current directory.
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
Jest 22.0.3
node 8.9.3
npm 5.6.0
Ubuntu 16.04.3 LTS
Here is the place in path.resolve source code that references process.cwd:
https://github.com/nodejs/node/blob/08941e9f1b3f1e8214e0a23d02b19bb07de8b951/lib/path.js#L203
Demo of how it works in vanilla node: https://repl.it/@borodean/jest-issue-process-cwd-node
@mjesun is this some issue with globals being injected and some not? Ref #2549
Yep; looks like it's caused by the fact that the process object on a test is not the real one, but a mocked version. Since all Node modules are required from the outer context (we tried fixing this in #4970, but we had to rollback as it's not mature enough yet), when you override process.cwd it's not the real one 馃槥.
Closing as dupe of #2549 then
@SimenB sorry to react to a closed issue, but I looked at the referenced issue and cannot figure out how the two are related and if any progress has been made. I'm running into the same problem with mocking process.cwd and process.resolve. Has any progress been made or is there a workaround available?
Most helpful comment
@SimenB sorry to react to a closed issue, but I looked at the referenced issue and cannot figure out how the two are related and if any progress has been made. I'm running into the same problem with mocking
process.cwdandprocess.resolve. Has any progress been made or is there a workaround available?