[英]Setting up jest, "test" is not a function
我有一個非常簡單的問題。 我很驚訝這似乎沒有被涵蓋。
我正在嘗試在節點 v14(非模塊,服務器端應用程序)中運行jest
。 “測試”function 在哪里? 我使用了 https://jestjs.io/docs/getting-started但沒有導入“測試”。當我導入笑話時,我看到了針對運行測試但沒有創建單元測試本身的函數。
> require('jest')
{
SearchSource: [Getter],
createTestScheduler: [Getter],
getVersion: [Getter],
run: [Getter],
runCLI: [Getter]
}
$ jest
FAIL test/exhibit.test.js
● Test suite failed to run
TypeError: test is not a function
13 | test('mytest', async function() {
我假設jest
腳本會使test
全局化,但看起來情況並非如此。
你不進口那些。 只需將此添加到您的 package.json
"scripts": {
"test": "jest ./",
}
其中./
是包含測試的最上層文件夾的路徑
然后運行jest
而不是運行:
npm run test
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.