Skip to content

Instantly share code, notes, and snippets.

@adamliptrot-oc
Created July 29, 2024 08:49
Show Gist options
  • Select an option

  • Save adamliptrot-oc/9cf4281033a4db2a2d9e3db7aee1163b to your computer and use it in GitHub Desktop.

Select an option

Save adamliptrot-oc/9cf4281033a4db2a2d9e3db7aee1163b to your computer and use it in GitHub Desktop.
Automating virtual screen-readers with Guidepup and Jest
test("should navigate to the input and announce the label and hint", async () => {
document.body.innerHTML = `
<form>
<label for="ref">What is your reference?</label>
<div class="hint" id="ref-hint">This is 10 characters.</div>
<input type="text" name="ref" id="ref" aria-describedby="ref-hint" />
<button>Save</button>
</form>
`;
await virtual.start({ container: document.body });
// Move to form
await virtual.perform(virtual.commands.moveToNextForm);
// Move to the input
await virtual.next();
await virtual.next();
await virtual.next();
const lastSpokenPhrase = await virtual.lastSpokenPhrase();
expect(lastSpokenPhrase).toContain("What is your reference?");
expect(lastSpokenPhrase).toContain("This is 10 characters");
await virtual.stop();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment