我正在嘗試將 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但沒有效果。
uj5u.com熱心網友回復:
您應該test從@jest/globals包中匯入函式。
const { expect, test } = require('@jest/globals');
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/369590.html
標籤:javascript 单元测试 玩笑
上一篇:VSCode上的Fortran
下一篇:總結一個SELECT查詢
