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 Dockerfile
s 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.