Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Jest tests cause 'TypeError: Cannot read property 'Symbol(Symbol.toStringTag)' of undefined'

I am using travis-ci for deployment of my open source projects. Without changes in my code, since yesterday all my builds fail to run unit tests with the next error:

~/w/some-package ❯❯❯ yarn test
yarn run v1.13.0
$ jest
 FAIL  test/unit/lib/sometest.js
  ● Test suite failed to run

    TypeError: Cannot assign to read only property 'Symbol(Symbol.toStringTag)' of object '#<process>'

      at _default (node_modules/jest-util/build/createProcessObject.js:85:34)

My build configuration uses the latest node and just runs the tests

language: node_js
node_js:
 - node
script:
 - yarn test

Was there any change of dependencies of travis-ci machines? is there any compatibility in between versions of node and jest?

like image 798
Kanekotic Avatar asked Sep 19 '25 01:09

Kanekotic


2 Answers

This seems to be an incompatibility in between node 11.11.0 that is the latest stable release and jest versions before 24.3.0.

There are currently 2 solutions:

  • Upgrade Jest (this will use a version of jest that is compatible with node 11.11)
yarn upgrade jest --latest
  • Pin version of node in .travis.yml (this will make sure that travis uses a version of node that is compatible with older jest versions)
language: node_js
node_js:
 - "10.15.3"
script:
 - yarn test
like image 115
Kanekotic Avatar answered Sep 22 '25 02:09

Kanekotic


Upgrading to jest 24.3.1 solves the issue as it was fixed in the version 24.3.0.

The pre-24.3.xversion are incompatible with node 11.11.0.

like image 25
Miroslav Jonas Avatar answered Sep 22 '25 02:09

Miroslav Jonas