component-driven / cypress-axe

Test accessibility with axe-core in Cypress
MIT License
622 stars 86 forks source link

How to disable standard output when using custom logging #107

Open mellis481 opened 3 years ago

mellis481 commented 3 years ago

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?