Pipeline jobs that previously succeeded now fail on rerun with TypeError during jest tests

,

Between april 20th and 21st our testing gitlab CI/CD pipeline started failing on commit. We thought that we had broken it ourselves (even though we did not change anything related to the test or the pipeline script) but after some testing we discovered that if we reran a job that previously succeeded it now also fails (obviously without any change to the code or the pipeline script). The error we get is during the “npx jest -ci” call; we get these errors for each test file:

FAIL xxxxx.test.js
70  ● Test suite failed to run
71    TypeError: Cannot redefine property: performance
72      at Object.<anonymous> (node_modules/react-native/jest/setup.js:445:20)

The pipeline forces the same version of npm and jest as our dev PCs on which the tests run just fine.
With the pipeline broken as it is we can’t release new versions of our application and it is therefore blocking us.

This can be reproduced with this simple pipeline script on our end:

image: node:alpine
before_script:
  - npm install npm@8.1.2 -g
  - apk add git
  - npm ci
stages:
  - test
  - release
jest-tests:
  stage: test
  script:
    - npx jest --v
    - npx jest --ci

We therefore suspect a change on gitlab’s end maybe related to an update or something. Any help would be appreciated on this!

That is odd. Have you tried pinning the node:alpine image to a particular version?

I don’t know why I didn’t think of that!
I forced the alpine version to the exact hash of the last pipeline job that succeeded and it fixed it.
For reference the last version that works for me is node:alpine@sha256:f61706c2cb120c06cf4fdcf60a2822a804b0bd90b6b2209be1ee00db1d33130c

Still its weird that it broke like that but well…

Thanks!

1 Like

FYI: Using before_script at the top level, but not in the default section, is deprecated