Skip to content
Advertisement

Jest : ReferenceError: describe is not defined

I try to setup jest for my project following this tutorial : https://dev.to/nedsoft/testing-nodejs-express-api-with-jest-and-supertest-1km6

But when I try to run a basic test I’ve got the error below :

 FAIL  tests/sample.test.js
  ● Test suite failed to run

    ReferenceError: describe is not defined

    > 1 | describe('Sample Test', () => {
        | ^
      2 |     it('should test that true === true', () => {
      3 |         expect(true).toBe(true)
      4 |     })

      at Object.<anonymous> (tests/sample.test.js:1:1)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.521 s
Ran all test suites.
(node:15452) ExperimentalWarning: The fs.promises API is experimental
npm ERR! Test failed.  See above for more details.

I try to remove in my package.json :

testEnvironment: 'node',

But nothing change.

A idea ?

Advertisement

Answer

Ok the problem is last version of jest has conflict with node 10.13.0

Source : https://github.com/facebook/jest/issues/9538

So make this and it is ok :

npm install --save-dev jest@25.2.2 supertest
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement