TestCafe-错误[ERR_HTTP_HEADERS_SENT]:将标头发送到客户端后,无法设置标头

时间:2020-05-04 15:31:26

标签: testing automation automated-tests e2e-testing testcafe

开始使用TestCafe在随机位置获得Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

我有一个本地节点模块,该模块是createTestCafe() api上的包装器。该模块称为testcafe-runner,并以"testcafe-runner": "file:local_modules/testcafe-runner"的形式安装。

除了以下例外,我开始收到错误消息:

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:485:11)
    at RequestPipelineContext.redirect (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe-hammerhead\lib\request-pipeline\context.js:278:9)
    at TestRun.handlePageError (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe\src\test-run\index.js:287:13)
    at SessionController.handlePageError (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe\src\test-run\session-controller.js:43:36)
    at error (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe-hammerhead\lib\request-pipeline\utils.js:81:48)
    at DestinationRequest.<anonymous> (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe-hammerhead\lib\request-pipeline\utils.js:62:9)
    at DestinationRequest.emit (events.js:209:13)
    at DestinationRequest.EventEmitter.emit (domain.js:476:20)
    at DestinationRequest._onError (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe-hammerhead\lib\request-pipeline\destination-request\index.js:171:17)
    at ClientRequest.<anonymous> (C:\MyTests\local_modules\testcafe-runner\node_modules\testcafe-hammerhead\lib\request-pipeline\destination-request\index.js:93:40) {
  domainThrown: true
}
npm ERR! code ELIFECYCLE
npm ERR! errno 7

所有测试javascript文件都位于C:\ MyTests文件夹中。

在本地模块和项目上安装的testcafe 1.8.4版本

1 个答案:

答案 0 :(得分:0)

我得到确切的错误。

testcafe - 1.8.4
OS - Mac Catalina
browser - chrome 81 
Node - 12.16.3

这是在单击logout按钮时发生的。
发生302重定向,最终用户被重定向回登录页面。

测试咖啡馆浏览器的网址显示为失败http://localhost:1337/03WvIUCEQ/about:error