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

Created on 6 Mar 2019  路  23Comments  路  Source: facebook/jest

馃毃 See https://github.com/facebook/jest/issues/8069#issuecomment-470520613 for status 馃毃

馃悰 Bug Report

My jest tests works in all node versions but not node 11.11

TypeError: Cannot assign to read only property 'Symbol(Symbol.toStringTag)' of object '#<process>'
  at _default (node_modules/jest-util/build/createProcessObject.js:85:34)

To Reproduce

https://travis-ci.org/juanjoDiaz/serverless-middleware/builds/502781207

Expected behavior

Jest behaves the same in all versions of Node.

Link to repl or repo (highly encouraged)

https://travis-ci.org/juanjoDiaz/serverless-middleware/builds/502781207

Issues without a reproduction link are likely to stall.

Bug

Most helpful comment

for those facing this issue: this happened after Node v11.11. the quickest fix is to downgrade Node to 11.10.1 in your CI lock file until further investigation

All 23 comments

for those facing this issue: this happened after Node v11.11. the quickest fix is to downgrade Node to 11.10.1 in your CI lock file until further investigation

Seeing the same problem this morning - downgrading to node 11.10.1 works as a temp fix

To save people using Travis some time, if you don't need the latest stable node you can modify your .travis.yml and add:

node_js:
- 8

Alternatively you can specify an earlier version of 11:

node_js:
- "11.10.1"

This has been fixed in #8050. Currently available as 24.2.0-alpha.0

[email protected] is now available as latest.
If you are stuck on an older version of Jest, you can wait for https://github.com/nodejs/node/pull/26488 or lock down your node version

I updated Jest to 24.3.1 but still see this error on node 11.11.0 on Travis CI, anyone else? 馃

What's the output of npm ls jest-util or yarn why jest-util?

@SimenB

oh I see... jest-environment-jsdom-thirteen could be the culprit here

+-- [email protected]
| `-- @jest/[email protected]
|   +-- [email protected]
|   | `-- [email protected]
|   `-- [email protected]
`-- [email protected]
  `-- [email protected]

It should be in semver range, so a npm dedupe might fix it

I updated Jest to 24.3.1 but still see this error on node 11.11.0 on Travis CI, anyone else? 馃

I tried both 24.2.0-alpha.0 and 24.3.0 and still got the same error. Every test passes locally and every test fails on Travis with this same error.

Do you have a lockfile? Or a cached node_modules on CI?

Do you have a lockfile? Or a cached node_modules on CI?

Not sure about cached node_modules, but I do have several package-lock.json files (in root and a few subdirectories). Maybe removing these and then reinstalling with Jest version 24.3.0 would help, do you think?

Woohoo! Thanks @SimenB , removing the lockfiles and reinstalling with the newer version of Jest fixed the problem. I appreciate your help!

Jest 24, user babel.config.js instead of .babelrc, I had to change it before it started working after upgrading from 23.6 to 24.4

@SimenB Could you backport the fix to Jest 23? It's been breaking CI for v23 users that include the latest version in their CI config.

The fix landed in Node a few hours ago, I think it's fine to either use a slightly older version of node on CI or wait for release of a new version of node

i guess i will have to wait for the fixed node version. because in my project we still use babel 6 and that seems to not be compatible with jest 24. it fixes this issue, but then seems to lead to issues when not migrated to babel 7

There were mainly two solutions for this problem

  1. Upgrade your jest version to 24.3.0 ( which didn't worked for me)
  2. Downgrade your node version to 11.10.1

I know that downgrading node version is not a good solution but for those who want to run your tests anyways can try it. By downgrading their node version from 11.11.1 to 11.10.1
Install package call "n" .
This n package helps you to Interactively Manage Your Node.js Versions

npm install -g  n

After installing it you just run

sudo n 11.10.1

and your node version will get changed you can check the node version by running

node --version

And later can run there test

npm test

It worked for me
I hope it will be helpful :)

still have this issue with jest version 24.5.0, the only thing helped is downgrading node to 11.10.1

New version of Node is out with a fix: https://nodejs.org/en/blog/release/v11.12.0/

@SimenB Seems there is no update for the current package (v11.12.0) on the arch packages yet.
https://www.archlinux.org/packages/community/x86_64/nodejs/

I don't know how or when arch do their updates, and that's not really relevant to this repo. The official release has dropped, when the different channels update is up to them 馃檪

None of the solutions above have helped me. You cannot upgrade Jest because react-scripts comes with version 23.x so you are just adding on top of what react-scripts would already have. You cannot upgrade react-scripts so that it will have jest@24 because the latest version has jest@23.

Changing to v11.10.1 does not help either and within my Dockerfile I have tried chainging the 'FROM' in my Dockerfile to FROM node:10.15-alpine and that has not helped.

This is so frustrating.

Was this page helpful?
0 / 5 - 0 ratings