Skip to content

Commit

Permalink
fix: snapshots get their own virtual screen reader
Browse files Browse the repository at this point in the history
fix: correct the minimum @guidepup/virtual-screen-reader peer dep version
  • Loading branch information
jlp-craigmorten committed Feb 28, 2024
1 parent f76affe commit 2c98758
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@guidepup/jest",
"version": "0.3.2",
"version": "0.3.3",
"description": "Virtual Screen Reader Jest Matchers",
"main": "lib/index.js",
"author": "Craig Morten <[email protected]>",
Expand Down Expand Up @@ -34,7 +34,7 @@
"jest-snapshot": "^29.7.0"
},
"peerDependencies": {
"@guidepup/virtual-screen-reader": "^0.16.1",
"@guidepup/virtual-screen-reader": "^0.14.0",
"jest": "^29"
},
"devDependencies": {
Expand Down
9 changes: 9 additions & 0 deletions src/__snapshots__/index.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`matchers snapshot matchers handles parallel assertions: toMatchScreenReaderSnapshot 1`] = `
[
"region",
"heading, Second Section Heading, level 1",
"Second Section Text",
"end of region",
]
`;

exports[`matchers toMatchScreenReaderSnapshot on a hidden node: toMatchScreenReaderSnapshot 1`] = `[]`;

exports[`matchers toMatchScreenReaderSnapshot on a null node: toMatchScreenReaderSnapshot 1`] = `[]`;
Expand Down
17 changes: 17 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,21 @@ describe("matchers", () => {
test("toMatchScreenReaderInlineSnapshot on a null node", async () => {
await expect(null).toMatchScreenReaderInlineSnapshot(`[]`);
});

test("snapshot matchers handles parallel assertions", async () => {
await Promise.all([
expect(
document.getElementsByTagName("section")[1]
).toMatchScreenReaderSnapshot(),
expect(document.getElementsByTagName("section")[1])
.toMatchScreenReaderInlineSnapshot(`
[
"region",
"heading, Second Section Heading, level 1",
"Second Section Text",
"end of region",
]
`),
]);
});
});
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { toMatchInlineSnapshot, toMatchSnapshot } from "jest-snapshot";
import { virtual } from "@guidepup/virtual-screen-reader";
import { Virtual } from "@guidepup/virtual-screen-reader";

// REF: https://jestjs.io/docs/en/expect.html#expectextendmatchers
declare global {
Expand All @@ -19,6 +19,8 @@ if (expect?.extend !== undefined) {
}

async function getScreenReaderOutput(container) {
const virtual = new Virtual();

let spokenPhraseLog: string[] = [];

try {
Expand Down

0 comments on commit 2c98758

Please sign in to comment.