TypeError: _fakeTimers(...).JestFakeTimers is not a constructor

Viewed 1220

I have a Node js server which has some tests running with jest. The result of the npm test ON LOCAL MACHINE is absolutely fine.

This Node js server runs inside a docker container. Here is the Dockerfile:

FROM node:12.14.1-alpine

RUN mkdir /usr/app

WORKDIR /usr/app

COPY . /usr/app
RUN apk update && apk upgrade && apk add --no-cache git
RUN npm install -g jest
RUN npm i
RUN npm test
CMD npm start

When we build the docker image, it breaks at RUN npm test stage with the following error:

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

    TypeError: _fakeTimers(...).JestFakeTimers is not a constructor

      at new JSDOMEnvironment (node_modules/jest-environment-jsdom/build/index.js:149:23)

I can't figure out why this is happening.

Any help will be appreciated.

Cross posting to Github

0 Answers
Related