我想通过发送 http 请求来触发 Protractor 测试,响应包含测试结果,如下面的代码片段所示。是否可以使用 Protractor 作为模块来允许我做到这一点?
var http = require('http');
http.createServer(function(request,response)
{
//call to execute protractor test
response.writeHead(200);
response.write("This should contain the test results");
response.end();
}
).listen(8080);
console.log("Listening on port 8080");
最佳答案
您可以将其作为子 shell 进程运行
这里是文档: https://nodejs.org/api/child_process.html
但是带有许多 E2E 测试的 Protractor 运行速度相当慢(在我的例子中大约 4 分钟)。您确定要坐下来等待结果吗?我建议异步组织这个。因此该请求只会运行一个调度 Protractor 并返回作业 ID,您可以不时获取作业 ID 状态。
关于javascript - 是否可以将 Protractor 作为 JavaScript 文件中的模块运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29350912/