{"size": 2272, "ext": "js", "max_stars_repo_path": "cypress/support/commands.js", "max_stars_repo_name": "ladyd252/gestalt", "max_stars_repo_stars_event_min_datetime": "2018-02-16T22:52:24.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T11:01:49.000Z", "max_issues_repo_path": "cypress/support/commands.js", "max_issues_repo_name": "ladyd252/gestalt", "max_issues_repo_issues_event_min_datetime": "2018-02-17T17:46:55.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-31T21:57:43.000Z", "max_forks_repo_path": "cypress/support/commands.js", "max_forks_repo_name": "ladyd252/gestalt", "max_forks_repo_forks_event_min_datetime": "2018-02-16T22:55:35.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-30T23:36:15.000Z"}
{"max_stars_count": 4038, "max_issues_count": 1564, "max_forks_count": 382, "avg_line_length": 25.5280898876, "max_line_length": 99, "alphanum_fraction": 0.5928697183}
import 'cypress-plugin-snapshots/commands';

function logA11yViolations(violations) {
  cy.task(
    'logToTerminal',
    `${violations.length} accessibility violation${violations.length === 1 ? '' : 's'} ${
      violations.length === 1 ? 'was' : 'were'
    } detected`,
  );

  // Overview of accessibility violations
  cy.task(
    'table',
    violations.map(({ id, impact, description, nodes }) => ({
      id,
      impact,
      description,
      nodes: nodes.length,
    })),
  );

  // In depth description of each violation
  cy.task(
    'logToTerminal',
    violations
      .map(
        ({ id, impact, description, help, helpUrl, nodes }, index) =>
          `

#${index}
id: ${id}
impact: ${impact}
description: ${description}
help: ${help}
helpUrl: ${helpUrl}
nodes: ${nodes.map(
            ({ failureSummary, html, target }, nodeIndex) => `

#${index}.${nodeIndex}
failureSummary:
${failureSummary}

html:
${html}

target:
${target.join('\n')}`,
          )}
  `,
      )
      .join('\n'),
  );
}

Cypress.Commands.overwrite('checkA11y', (originalFn, context, options) => {
  // Do not test accessibility on the live code editors, or anything with class="cypress-skip-a11y"
  const accessibilityExcludes = {
    'exclude': [['.live-editor-pane'], ['.cypress-skip-a11y']],
  };
  const updatedContext = { ...context, ...accessibilityExcludes };
  return originalFn(updatedContext, options, logA11yViolations);
});

// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add("login", (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
