[英]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.