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 error in Node version over 11.11

See original GitHub issue

PS. I do not speak English well. Please understand.

Is this a bug report?

Yes

Did you try recovering your dependencies?

yes / Initialized project with npx create-react-app my-project

Which terms did you search for in User Guide?

jest, jest version

Environment

$ npx create-react-app --info npx: installed 63 in 8.392s

Environment Info:

System: OS: Linux 4.4 Ubuntu 18.04.2 LTS (Bionic Beaver) CPU: x64 Intel® Core™ i7-8700K CPU @ 3.70GHz Binaries: Node: 11.11.0 - ~/.nvm/versions/node/v11.11.0/bin/node Yarn: 1.13.0 - /usr/bin/yarn npm: 6.7.0 - ~/.nvm/versions/node/v11.11.0/bin/npm npmPackages: react: ^16.8.4 => 16.8.4 react-dom: ^16.8.4 => 16.8.4 react-scripts: 2.1.8 => 2.1.8 npmGlobalPackages: create-react-app: Not Found

Steps to Reproduce

  1. install node version 11.11. (only over 11.11. There is no problem with other versions.)
  2. npx create-react-app myproject && cd myproject
  3. yarn test # this step error

Expected Behavior

Currently, the LTS version of node.js is 10, but will change from 2019-04-01 to version 11. That’s why I think we need to fix the problem.

This problem has been fixed as follows after facebook/jest@800f2f803d01c8ae194d71b251e4965dd70e5bf2 (v24.2.0-alpha.0).

newProcess[Symbol.toStringTag] = 'process';

modify to

 try {
    // This fails on Node 12, but it's already set to 'process'
    newProcess[Symbol.toStringTag] = 'process';
  } catch (e) {
    // Make sure it's actually set instead of potentially ignoring errors
    if (newProcess[Symbol.toStringTag] !== 'process') {
      e.message =
        'Unable to set toStringTag on process. Please open up an issue at https://github.com/facebook/jest\n\n' +
        e.message;

      throw e;
    }
  }

I used the 10.15.3 node and tried the 24.3.0 Jest. As a result, it worked fine. But I have not tested it for other versions of the node.

Actual Behavior

$ CI=true yarn test
yarn run v1.13.0
$ react-scripts test
FAIL src/App.test.js
  ● Test suite failed to run

    TypeError: Cannot assign to read only property 'Symbol(Symbol.toStringTag)' of object '#<process>'

      at exports.default (node_modules/jest-util/build/create_process_object.js:15:34)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        3.291s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

The same is true without “CI=true”.

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:55
  • Comments:38 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
somedencommented, Mar 8, 2019

There is no error with node v11.10.1, but it is with v11.11.0 Example v11.10.1:

npx create-react-app my-app
cd my-app
docker run -it --rm -v $(PWD):$(PWD) -w $(PWD) node:11.10.1-alpine yarn test

 PASS  src/App.test.js (13.661s)
  ✓ renders without crashing (48ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        20.784s

Example v11.11.0:

npx create-react-app my-app
cd my-app
docker run -it --rm -v $(PWD):$(PWD) -w $(PWD) node:11.11.0-alpine yarn test

 FAIL  src/App.test.js
  ● Test suite failed to run

    TypeError: Cannot assign to read only property 'Symbol(Symbol.toStringTag)' of object '#<process>'

      at exports.default (node_modules/jest-util/build/create_process_object.js:15:34)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        5.643s
8reactions
FezVrastacommented, Mar 12, 2019

Hey guys, lot of people are subscribed to this issue to be warned when a fix gets released. Please may you refrain from posting all your very own personal solutions that explain how did you downgrade your Docker images to use node <11.11 please?

Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - Jest not updating in react and conflicting with jest in ...
It looks like my error is because the versions of jest in create react app are out of date causing the problem. How...
Read more >
VSCode Jest extension using the wrong version of Node
The error it is giving me here TypeError: this.children.flatMap is not a function is the Jest tests running in the wrong node runtime...
Read more >
Troubleshooting - Jest
Troubleshooting. Uh oh, something went wrong? Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why​.
Read more >
jsdom - npm
jsdom is a pure-JavaScript implementation of many web standards, notably the WHATWG DOM and HTML Standards, for use with Node.js.
Read more >
Travis/Jest: TypeError: Cannot assign to read only property ...
That is a bug that came with node v11.11. You can downgrade to v11.10 or wait for the fix which facebook has already...
Read more >

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