Cypress pipe console.log and command log to output

前端 未结 3 1335
再見小時候
再見小時候 2020-12-31 04:17

Is it possible to redirect or capture Cypress browser log and command log to output?

I read some Cypress github issues on this topic. But I don\'t know how to make

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-31 04:52

    Expanding on @Joshua-wade's answer, you can overwrite cy.log to redirect all calls to it to the log task. Just as the following:

    Cypress.Commands.overwrite('log', (subject, message) => cy.task('log', message));

    Note: there's a small drawback to this: when you run the test using the Test Runner, instead of seeing LOG my message in the command log, you'll see TASK log, my message. But IMHO it's negligible.

提交回复
热议问题