【发布时间】:2022-01-05 22:06:57
【问题描述】:
我正在尝试将 Jest 测试添加到 vanilla JS 项目中。我用 npm 安装了 Jest,并创建了一个示例测试文件:
// file example.test.js
const { expect } = require("@jest/globals");
const { test } = require("jest-circus");
const one = 1;
test("example test", () => {
expect(one).toBe(1);
});
但我收到以下错误:
FAIL ./example.test.js
● Test suite failed to run
Your test suite must contain at least one test.
at onResult (node_modules/@jest/core/build/TestScheduler.js:175:18)
at Array.map (<anonymous>)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.437 s
Ran all test suites.
不确定可能有什么问题?我显然在测试文件中有一个测试/预期块。我也尝试将test 更改为it,但没有效果。
【问题讨论】:
-
您缺少
describe代码块。
标签: javascript unit-testing jestjs