玩笑:ReferenceError:未定义描述

Ver*_*uze 1 javascript jestjs

我尝试按照本教程为我的项目设置 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.
Run Code Online (Sandbox Code Playgroud)

我尝试在我的 package.json 中删除:

testEnvironment: 'node',
Run Code Online (Sandbox Code Playgroud)

但什么都没有改变。

一个想法?

Ver*_*uze 7

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

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

所以做这个就可以了:

npm install --save-dev jest@25.2.2 supertest
Run Code Online (Sandbox Code Playgroud)