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 :
JavaScript
x
21
21
1
FAIL tests/sample.test.js
2
● Test suite failed to run
3
4
ReferenceError: describe is not defined
5
6
> 1 | describe('Sample Test', () => {
7
| ^
8
2 | it('should test that true === true', () => {
9
3 | expect(true).toBe(true)
10
4 | })
11
12
at Object.<anonymous> (tests/sample.test.js:1:1)
13
14
Test Suites: 1 failed, 1 total
15
Tests: 0 total
16
Snapshots: 0 total
17
Time: 1.521 s
18
Ran all test suites.
19
(node:15452) ExperimentalWarning: The fs.promises API is experimental
20
npm ERR! Test failed. See above for more details.
21
I try to remove in my package.json :
JavaScript
1
2
1
testEnvironment: 'node',
2
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 :
JavaScript
1
2
1
npm install --save-dev jest@25.2.2 supertest
2