TransWikia.com

How to save the console log in Cypress rather than letting it display in the terminal?

Stack Overflow Asked by Tester1 on February 21, 2021

I have used this code:

const cucumber = require('cypress-cucumber-preprocessor').default

module.exports = (on, config) => {
  on('file:preprocessor', cucumber())

  on(`task`, {
    log(message) {
      console.log("x1b[31m", "LOG:", message, "x1b[0m")
    },
    info(message) {
      console.info("x1b[33m", "INFO:", message, "x1b[0m")
    },
  });
};

and also this:

Cypress.on('window:before:load', win => {
  cy.stub(win.console, 'log', msg => {
    cy.now("task", "log", msg)
  });

  cy.stub(win.console, 'info', msg => {
    cy.now("task", "info", msg)
  });

It is showing my console in the terminal, however, I want to save the terminal log so that I can see all the console log.

Can anyone help?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP