是否可以将 运行 量角器作为 javascript 文件中的模块?

Is it possible to run protractor as a module from a javascript file?

我想通过发送 http 请求来触发量角器测试,响应包含测试结果,如下面的代码片段所示。是否可以使用量角器作为模块来允许我这样做?

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");

你可以 运行 它作为一个 child shell 过程

这是文档: https://nodejs.org/api/child_process.html

但是带有许多 E2E 测试的量角器 运行 非常慢(在我的情况下大约 4 分钟)。您确定要坐下来等待结果吗?我建议异步组织。所以请求只会一个调度量角器运行ning和return作业ID,你可以不时获取作业ID状态。