Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 是否可以在节点服务器内运行AVA测试?_Node.js_Unit Testing_Testing_Automated Tests_Ava - Fatal编程技术网

Node.js 是否可以在节点服务器内运行AVA测试?

Node.js 是否可以在节点服务器内运行AVA测试?,node.js,unit-testing,testing,automated-tests,ava,Node.js,Unit Testing,Testing,Automated Tests,Ava,我希望用户提交代码并使用AVA对该代码运行测试。AVA CLI看起来很棒。但这将在Heroku这样的托管环境中运行,并且需要用单元测试的结果响应包含代码提交的POST请求 当我尝试var test=require('ava')然后在路由中调用test函数时,我在启动节点服务器时收到以下消息: [OKAY] Loaded ENV .env File as KEY=VALUE Format 10:24:11 PM web.1 | Test files must be run with the AV

我希望用户提交代码并使用AVA对该代码运行测试。AVA CLI看起来很棒。但这将在Heroku这样的托管环境中运行,并且需要用单元测试的结果响应包含代码提交的POST请求

当我尝试
var test=require('ava')
然后在路由中调用
test
函数时,我在启动节点服务器时收到以下消息:

[OKAY] Loaded ENV .env File as KEY=VALUE Format
10:24:11 PM web.1 |  Test files must be run with the AVA CLI:
10:24:11 PM web.1 |      $ ava index.js
[DONE] Killing all processes with signal  null
10:24:11 PM web.1 Exited with exit code 1

我认为这是不可能的,它被认为是通过cli使用的。事实上,对我来说,将其用作代码中的必需模块没有多大意义

你打算如何使用它?如果您只想使用断言,您可以使用一些断言库,如,或

如果您需要更多信息,也可以选择在AVA回购中发行债券