cypress-axe icon indicating copy to clipboard operation
cypress-axe copied to clipboard

How to disable standard output when using custom logging

Open mellis481 opened this issue 4 years ago • 0 comments

I'm using the violationCallback parameter of cy.checkA11y() to implement custom logging. Like this:

cy.checkA11y(undefined, undefined, showViolations);

const showViolations = (violations: Result[]) => {
  violations.forEach((violation: Result) => {
    const { nodes, helpUrl, help, impact } = violation;
    const nodesList = nodes.map((node: NodeResult) => node.target).join(', ');

    const name = `${impact || ''} a11y error`;
    const message = `[${help}](${helpUrl}) affecting the following node(s): [${nodesList}]. Check the console for additional error details.`;

    Cypress.log({
      name,
      message,
      consoleProps: () => violation,
      $el: Cypress.$(nodesList),
    });
  });
};

When I do this, I see my custom logs followed by the standard output. Eg:

image

I don't want to see the standard output if I have custom logging in place. How can I accomplish this?

mellis481 avatar Sep 30 '21 13:09 mellis481