我尝试按照本教程为我的项目设置玩笑:https://dev.to/nedsoft/testing-nodejs-express-api-with-jest-and-supertest-1km6
但是当我尝试运行基本测试时,出现以下错误:
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.
我尝试在我的package.json中删除:
testEnvironment: 'node',
但是什么都没有改变。
一个想法?
好,问题是玩笑的最新版本与节点10.13.0有冲突
来源:https://github.com/facebook/jest/issues/9538
所以做这个就可以了:
npm install --save-dev [email protected] supertest