PS. I do not speak English well. Please understand.
Yes
yes / Initialized project with npx create-react-app my-project
jest, jest version
$ 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(R) Core(TM) 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
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.
$ 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".
(Paste the link to an example project and exact instructions to reproduce the issue.)
same here.
I'm getting the same error
Experiencing the same on node@latest, downgrading to node 10.6.0 makes everything fine and dandy.
Me too the same error. Hey @viktorlarsson what if reactjs ?
Got the same error on the latest node image
Same here
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
same here
Same here
Please fix this :(
If you need to get this to work with node 11.11 and you cannot downgrade...
It is already fixed with newer jest version.
You can upgrade your own jest version besides create-react-app by installing jest-util@^23.4.0
Also you have to create a .env-File and to bypass the Preflight-Check.
echo "SKIP_PREFLIGHT_CHECK=true" >> .env
The complete cmd that solves the issue for myself is:
echo "SKIP_PREFLIGHT_CHECK=true" >> .env && npm i jest-util@^23.4.0 --save-dev
Until create-react-app has updated to newer jest-version, we can remove jest from our package.json and also reactivate this skipped preflight-check.
if you use gitlab CI you can change image: node:latest
into image: node:10.6.0
What worked for me was changing the version of Jest to 24.3.0
. I also had to remove the lockfiles and reinstall before tests passed again on Travis. Hope this helps.
[email protected] works fine, you don't need to downgrade to 10.6. The one with problems is [email protected]
What worked for me was changing the version of Jest to
24.3.0
. I also had to remove the lockfiles and reinstall before tests passed again on Travis. Hope this helps.
As @Marjona6 stated it's fixed since version 24.3.0 so this issue should be closed.
its not fixed in create-react-app since it doesn't bring jest 24 with it. It should be "awaiting" for this PR to be merged: https://github.com/facebook/create-react-app/pull/6278
NOT fixed when using create-react-app.
I set node_js to 11.10.0 and jest to 24.3.1 and it still fails for the same issue on travis.
Travis build still failing for create-react-app.
Things I have tried:
All as per instructions in error log at travis-ci.
Nothing has worked for me.
Thank you all. I solved this by using node 11.10.
@Marjona6
I think this is caused by setting the Symbol.toStringTag member to read-only on the process object as the node version goes up to 11.11.
However, this can change in this PR(nodejs/node#26488) to Writable. So I'm not sure yet.
@rpearce63, @DavidOD
Both are using node:alpine in Dockerfile. This version is 11.11.
Changing the Dockerfile to reference a different node version has no effect at Travis-CI
I managed to solve this issue by migrating from Travis to Circle CI, I think there some additional configurations needed in Travis CI. @DavidOD
@micalgenus
When I run docker-compose up locally using that same node:alpine, the tests run successfully. The only difference seems to be running it on the Travis-CI
@rpearce63, @DavidOD
Both are using node:alpine in Dockerfile. This version is 11.11.
@rpearce63
Maybe the image of node:alpine already exists, so it was tested on 11.10?
I got the results below.
[root@localhost cra-jest]# docker run -it --rm -v $(pwd):$(pwd) -w $(pwd) node:alpine node --version
v11.11.0
[root@localhost cra-jest]# docker run -it --rm -v $(pwd):$(pwd) -w $(pwd) node:alpine sh -c "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: 0.422s
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.
I'm not sure about other cases. 😢
@micalgenus
Quick test...looks like node:alpine, at least the image I had cached, was using 11.10.
docker run -it node:alpine sh
/ # node -v
v11.10.1
/ #
Then I pulled an updated node:alpine and tried again. Now it says v11.11. So that might be the case that when Travis pulls the image for the build, it's using v11.11. I'll try specifying another version.
Thanks...
Edited to add:
Bingo. I changed my Dockerfile to use node:11.10-alpine and reran docker-compose up --build. With the v11.11 version I got the same error described here. After changing the node image version in Dockerfile, the build and deploy locally was successful. I'm going to commit that change and see if Travis succeeds.
-- I updated the Dockerfile to use node:11.10-alpine and commited the change. The Travis build succeeded this time with the tests passing. It took a bit to realise the version of node running on Travis was not the issue as this is a Docker image. It's the version of node running in the container. Setting the image version to a pre 11.11 fixed it.
@rpearce63
Maybe the image of node:alpine already exists, so it was tested on 11.10?
Had the same issue BUT not with CRA project, just with _node_ and _jest_ together.
solution:
npm i
npm run test
back to green.
Travis-Ci build success!
Confirm: changing Dockerfile to use node:11.10-alpine has fixed my problems at travis-ci. I did the same thing a couple of days ago and it didn't work, but now it does. No need to change .travis.yml, or any other settings. Thanks guys.
I was using node:10.15-alpine
when I encountered this problem. I subsequently tried to
node:11.10-alpine
node:11.9-alpine
package-lock.json
and reinstall node_modules
I cannot force the newer Jest version because I cannot use a separate .env
file. My .env
files are generated per environment. I don't really want to skip the preflight checks. I'm thinking I'll try different node versions until something works. I'm hoping this gets a create-react-app
fix soon.
If jest is in your sub-deps -like react-script
users- you can force your project to use an exact version like below:
package.json
{
dependencies: { "bla": "bla"},
"resolutions": {
"jest": "^24.3.0"
}
}
OK, my problem was that my bitbucket-pipelines.yml
was using an unspecified version of alpine, which selects the latest one by default. It was a simple fix at the end and a silly overlooked mistake on my part. In other words I changed images with node:alpine
to node:10.15-alpine
.
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?
None of the solutions in this thread have helped me, so yes, please refrain from posting what personally worked for you until a solution exists that works for everybody, this is frustrating.
None of the solutions in this thread have helped me, so yes, please refrain from posting what personally worked for you until a solution exists that works for everybody, this is frustrating.
How are you supposed to know if it works for everyone or not?
We've released an alpha of create-react-app 3.0. Head on over to #6475 for instructions to install the latest alpha build which includes Jest 24. Let us know if it solves this issue!
@ianschmitz Yes, it solved the problem 👍
node 11.12 fixed it
Ok
Closing as it sounds like this is resolved in Node 11.12
Most helpful comment
There is no error with node v11.10.1, but it is with v11.11.0
Example v11.10.1:
Example v11.11.0: