Skip to content

Commit 983b162

Browse files
committed
test: simplified a11y testing
1 parent 0069b2e commit 983b162

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

packages/kit-headless/cypress/support/component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ addQwikLoader();
2020
// Import commands.ts using ES2015 syntax:
2121
import './commands';
2222
import 'cypress-axe';
23+
import 'axe-core';
2324

2425
// Augment the Cypress namespace to include type definitions for
2526
// your custom command.
@@ -30,11 +31,15 @@ declare global {
3031
namespace Cypress {
3132
interface Chainable {
3233
mount: typeof mount;
34+
checkA11yForComponent: () => void;
3335
}
3436
}
3537
}
3638

3739
Cypress.Commands.add('mount', mount);
40+
Cypress.Commands.add('checkA11yForComponent', () => {
41+
cy.checkA11y('[data-cy-root]');
42+
});
3843

3944
// Example use:
4045
// cy.mount(MyComponent)

packages/kit-headless/src/components/accordion/accordion.spec.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Accordion, AccordionItem } from './accordion';
33

44
describe('Accordion', () => {
55
it('should render an Accordion', () => {
6-
cy.injectAxe({ axeCorePath: '../../node_modules/axe-core/axe.min.js' });
76
mount(
87
<Accordion class="accordion">
98
<AccordionItem label="Heading 1">
@@ -25,6 +24,6 @@ describe('Accordion', () => {
2524
cy.get('.content').should('exist');
2625
cy.contains(/Heading 2/i).should('exist');
2726

28-
cy.checkA11y('[data-cy-root]');
27+
cy.checkA11yForComponent();
2928
});
3029
});

0 commit comments

Comments
 (0)