gpt4 book ai didi

javascript - Jest : ReferenceError: describe is not defined

转载 作者:行者123 更新时间:2023-12-05 08:50:29 25 4
gpt4 key购买 nike

我尝试按照本教程为我的项目设置 Jest :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',

但没有任何改变。

一个想法?

最佳答案

好的,问题是 jest 的最新版本与节点 10.13.0 有冲突

来源:https://github.com/facebook/jest/issues/9538

所以做这个就可以了:

npm install --save-dev jest@25.2.2 supertest

关于javascript - Jest : ReferenceError: describe is not defined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61912996/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com