[Bug]: jest fails when @cspot/source-map-support and yarn 2+ pnp are involved.
See original GitHub issueVersion
27.5.1
Steps to reproduce
Use this repo: https://github.com/noahnu/repro-source-map-error (h/t @noahnu for making this)
yarn install
yarn ts-node --transpile-only $(yarn bin jest)
Expected behavior
Test should pass.
Actual behavior
% yarn ts-node --transpile-only $(yarn bin jest)
FAIL ./index.test.ts
● Test suite failed to run
Cannot find module 'source-map-support' from '/Users/francis/temp/repro-source-map-error/.yarn/cache/@cspotcode-source-map-support-npm-0.7.0-456c3ea2ce-9faddda775.zip/node_modules/@cspotcode/source-map-support'
at resolveSync (.yarn/cache/resolve-patch-bad885c6ea-c79ecaea36.zip/node_modules/resolve/lib/sync.js:111:15)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.132 s
Ran all test suites.
Additional context
The original issue is: https://github.com/cspotcode/node-source-map-support/issues/35, but it seems to be a Jest problem.
Here is the a patch that fixes it (thanks to @cspotcode )
Replace this code:
with:
const resolved = require.resolve('source-map-support');
runtime.requireInternalModule(resolved, resolved).install(sourcemapOptions);
This might be related to:
https://github.com/facebook/jest/issues/8930 https://github.com/facebook/jest/issues/11453
Environment
System:
OS: macOS 12.1
CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
Binaries:
Node: 14.17.3 - ~/.nvm/versions/node/v14.17.3/bin/node
Yarn: 3.1.1 - /usr/local/bin/yarn
npm: 8.1.0 - ~/.nvm/versions/node/v14.17.3/bin/npm
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:17 (5 by maintainers)
Top Results From Across the Web
jest-environment-jsdom | Yarn - Package Manager
Fixed support for running Jest as a git submodule. ... Fixed test runtime error reporting and stack traces. Improved toBeCalled Jasmine 2 custom...
Read more >How to debug Jest Tests when using Yarn 2 / Yarn PnP
I was able to run our jest tests using node and some debugging flag helpers (in a Yarn pnp context) using this command:...
Read more >Getting Started - Jest
Note: Jest documentation uses yarn commands, but npm will also work. You can compare yarn and npm commands in the yarn docs, here....
Read more >Error cannot find module */jest-intellij-stdin-fix.js when using ...
Error cannot find module */jest-intellij-stdin-fix.js when using Yarn 3 pnp · 1. Install Nodejs version 16.14.0 · 2. Enable corepack via corepack ...
Read more >除错 - Yarn 中文文档
This error simply means that the specified package is requiring something ... require(`jest-environment-${config.environment}`) - in this circumstances the ...
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 FreeTop 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
Top GitHub Comments
Interestingly enough I had this error in CI (Ubuntu), but it worked fine locally (Windows). Added this to my
.yarnrc.yml
while waiting for this to get fixed:Naturally