4

I'd like to print arbitrary outputs to the terminal per each test after calling cypress run. The outputs should appear regardless of each test's success/failure. I've followed the instructions from dozens of online answers - nothing worked for me.

I'm using Cypress 8.7.0. Thanks!

2

1 Answer 1

7

It's pretty much what @nozik linked to. In your cypress.config.js add:

module.exports = defineConfig({ e2e: { setupNodeEvents(on, config) { on('task', { log(message) { // Then to see the log messages in the terminal // cy.task("log", "my message"); console.log(message +'\n\n'); return null; }, }); }, }, }); 

which can then be called in your tests with:

 cy.task('log', 'Display some logging'); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.