j40-cejst-2/client/cypress/e2e/accessibility.test.js
Nat Hillard 7b241795fa
Cypress tests are failing locally (#403)
* adding readme with debug instructions
* updating translation tests to pass
* fixes failing latlng url test
* localizing focus buttons
* updating map tests to pass
* temporarily setting to only flag critical+  accessibility errors. To be addressed with full accessibility audit later
2021-07-23 08:52:34 -04:00

34 lines
888 B
JavaScript

// / <reference types="Cypress" />
// Define at the top of the spec file or just import it
// eslint-disable-next-line require-jsdoc
function terminalLog(violations) {
cy.task(
'log',
`${violations.length} accessibility violation${
violations.length === 1 ? '' : 's'
} ${violations.length === 1 ? 'was' : 'were'} detected`,
);
// pluck specific keys to keep the table readable
const violationData = violations.map(
({id, impact, description, nodes}) => ({
id,
impact,
description,
nodes: nodes.length,
}),
);
cy.task('table', violationData);
}
describe('Accessibility tests', () => {
beforeEach(() => {
cy.visit('/').get('main').injectAxe();
});
it('Has no detectable accessibility violations on load', () => {
cy.checkA11y(null, {includedImpacts: ['critical']}, terminalLog);
});
});