是否可以重定向或捕获赛普拉斯浏览器日志和命令日志以输出?
我读了一些 Cypress githubissues https://github.com/cypress-io/cypress/issues/448关于这个话题。但我不知道如何让它发挥作用。
基本上,我想在无头非 GUI 模式下捕获所有 Cypress GUI 命令日志。如果我可以包括浏览器控制台日志会更好。目的是了解测试失败时发生的情况。
我使用 teamcity 作为 ci。这是我的构建日志的示例。我也想在这里查看所有命令日志。实际上,任何console.log都在服务器端运行cy.task
显示在构建日志中。跑步cy.task('log',message)
太手动了。有什么更聪明的方法吗?
[09:49:08][Step 1/1] 2 of 4: new actions (52s)
[09:50:00][Step 1/1] 3 of 4: new actions (52s)
[09:50:53][Step 1/1] 4 of 4: new actions (53s)
[09:51:47][Step 1/1] (Results)
[09:51:47][Step 1/1]
[09:51:47][Step 1/1] ┌─────────────────────────────────────┐
[09:51:47][Step 1/1] │ Tests: 8 │
[09:51:47][Step 1/1] │ Passing: 8 │
[09:51:47][Step 1/1] │ Failing: 0 │
[09:51:47][Step 1/1] │ Pending: 0 │
[09:51:47][Step 1/1] │ Skipped: 0 │
[09:51:47][Step 1/1] │ Screenshots: 0 │
[09:51:47][Step 1/1] │ Video: true │
[09:51:47][Step 1/1] │ Duration: 3 minutes, 38 seconds │
[09:51:47][Step 1/1] │ Estimated: 1 minute, 8 seconds │
[09:51:47][Step 1/1] │ Spec Ran: action/action_spec.js │
[09:51:47][Step 1/1] └─────────────────────────────────────┘
从 Cypress 3.0.0 开始,您可以使用cy.task()
直接访问节点并输出到节点控制台。来自文档:
// in test
cy.task('log', 'This will be output to the terminal')
// in plugins file
on('task', {
log (message) {
console.log(message)
return null
}
})
See here https://docs.cypress.io/api/commands/task.html了解更多信息。
我不知道有什么方法可以将 Cypress 日志直接镜像到控制台,但这至少是一个可行的替代方案。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)