import React from 'react'; import { mount } from '@cypress/react'; import { getFocusTargets } from '../focus'; it('detects typical focusable elements', () => { const Tabbables = () => (
No href Link
Tabbable
); mount(); cy.get('#start').focus(); const actualTargets: HTMLElement[] = []; for (let i = 0; i < 5; i++) { cy.realPress('Tab'); cy.focused().should('not.have.class', 'ignored').then($el => { actualTargets.push($el.get(0)); }); } cy.get('.targets').then($el => { const element = $el.get(0); expect(getFocusTargets(element)).to.deep.equal(actualTargets); }); });