0

So I ran my Docker build with TravisCI and I got a failure like so:

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)

I did not think that this App.test.js file would give me problems after I removed the logic from within the it block like so:

import React from "react";
import ReactDOM from "react-dom";
import App from "./App";

it("renders without crashing", () => {});

I thought the issue may have been the latest release of node because I saw others have similar error messages, so I changed my version like so:

FROM node:10.15-alpine as builder OR FROM node:10.15-alpine as I have various Dockerfiles for each service I am building as this is a multi-container project.

That change I made did not resolve the issue, TravisCI continues to fail my build with the same exact error, what gives here?

I thought perhaps the issue would be a version of Jest mismatch, but I have not installed any version of Jest, this is my package.json file inside my client/src/App.test.js:

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.8.3",
    "react-dom": "^16.8.3",
    "react-scripts": "2.1.5",
    "react-router-dom": "4.3.1",
    "axios": "0.18.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

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 changing the 'FROM' in my Dockerfile to FROM node:10.15-alpine and that has not helped.

When I tested it in this manner:

docker run -it --rm -v $(PWD):$(PWD) -w $(PWD) node:10.15-alpine npm test

it passed!

 PASS  src/App.test.js (10.163s)

  ✓ renders without crashing (5ms)

But it does not pass in TravisCI

This is my Dockerfile for my client/src directory:

FROM node:10.15-alpine as builder
WORKDIR '/app'
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

FROM nginx
EXPOSE 3000
COPY --from=builder /app/build /usr/share/nginx/html

I even tried changing my .travis.yml file to this:

- docker run -it --rm -v myproject/react-test node:10.15-alpine npm test -- --coverage,

when it was originally this:

script:
  - docker run myproject/react-test npm test -- --coverage

Absolutely nothing appears to be working here.

1 Answer 1

0

You cannot rely on FROM node:10.15-alpine alone to fix this. I had to go with the fix from the facebook team. So if anyone else did not get a fix from modifying your Dockerfile to node:10.15-alpine, go to your package.json file and change react-scripts to the following facebook fix:

"react-scripts": "3.0.0-next.b0cbf2ca"

Then go ahead and remove your node_modules/ folder via rm -rf node_modules and then run npm install, check your jest-util file, it should now have an output like this:

└─┬ [email protected]
  ├─┬ [email protected]
  │ └─┬ @jest/[email protected]
  │   ├─┬ [email protected]
  │   │ └── [email protected]  deduped
  │   └── [email protected]
  └─┬ [email protected]
    └─┬ [email protected]
      ├─┬ @jest/[email protected]
      │ ├─┬ @jest/[email protected]
      │ │ └── [email protected]  deduped
      │ ├─┬ [email protected]
      │ │ └── [email protected]  deduped
      │ ├─┬ [email protected]
      │ │ └── [email protected]  deduped
      │ ├── [email protected]  deduped
      │ └─┬ [email protected]
      │   └── [email protected]  deduped
      ├─┬ [email protected]
      │ ├─┬ [email protected]
      │ │ └── [email protected]  deduped
      │ ├─┬ [email protected]
      │ │ └── jest-u[email protected]  deduped
      │ ├─┬ [email protected]
      │ │ ├─┬ [email protected]
      │ │ │ └── [email protected]  deduped
      │ │ └── [email protected]  deduped
      │ └── [email protected]  deduped
      └── [email protected]  deduped

You should be good to run TravisCI build now. The issue is the react-scripts version 2.1.8 is conflicting with new version of Node. Suffered through this all day long, grateful to the facebook team for getting back to me.

For reference: https://github.com/facebook/create-react-app/issues/6475

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.