Hey everyone I am trying to log window console commands to the CLI output for cypress run (it seems like a lot of people have tried to do this.) I tried to stub these commands and pass the arguments to a task. But it seems like you can't call a cy.task in a callback with out a promise error. Does anyone have this working?
Here is what I tried to do.:
Cypress.on('window:before:load', (win) => {
cy.stub(win.console, 'log').callsFake((...messages) => {
cy.task('logToCLI', messages)
});
});
setupNodeEvents(on, config) {
on('task', {
logToCLI(messages: string[]) {
console.log(...messages);
return null;
}
})
This is the error that I get when I try that : > Cypress detected that you returned a promise from a command while also invoking one or more cy commands in that promise.