-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: build tweaks to support legacy TS setups (#80)
- Loading branch information
1 parent
f9962a0
commit 0192ecf
Showing
40 changed files
with
11,109 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# CommonJS Example | ||
|
||
A basic example using the Virtual Screen Reader in a CommonJS application. | ||
|
||
Run this example with: | ||
|
||
```bash | ||
# Install and build core package | ||
yarn install --frozen-lockfile | ||
|
||
# Navigate to example, install, and test | ||
cd examples/commonjs | ||
yarn install --frozen-lockfile | ||
yarn test | ||
``` | ||
|
||
> [!IMPORTANT] | ||
> This example serves to demonstrate how you can use the Virtual Screen Reader. The components themselves may not be using best accessibility practices. | ||
> | ||
> Always evaluate your own components for accessibility and test with real users. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// eslint-disable-next-line no-undef | ||
module.exports = { | ||
testEnvironment: "jsdom", | ||
roots: ["src"], | ||
collectCoverageFrom: ["**/*.js"], | ||
coveragePathIgnorePatterns: [], | ||
coverageThreshold: { | ||
global: { | ||
branches: 100, | ||
functions: 100, | ||
lines: 100, | ||
statements: 100, | ||
}, | ||
}, | ||
setupFilesAfterEnv: ["<rootDir>/jest.setup.js"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
jest.setTimeout(10000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@guidepup/virtual-screen-reader-commonjs-example", | ||
"version": "1.0.0", | ||
"author": "Craig Morten <[email protected]>", | ||
"license": "MIT", | ||
"private": true, | ||
"scripts": { | ||
"preinstall": "yarn --cwd=../.. build", | ||
"test": "jest" | ||
}, | ||
"devDependencies": { | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`matchers virtual screen reader tests navigating headings 1`] = ` | ||
[ | ||
"document", | ||
"heading, First Section Heading, level 1", | ||
"heading, Article Header Heading, level 1", | ||
"heading, Second Section Heading, level 1", | ||
"heading, First Section Heading, level 1", | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const { virtual } = require("../../../lib/cjs/index.js"); | ||
// In your code, replace with: | ||
// const { virtual } = require("@guidepup/virtual-screen-reader"); | ||
|
||
function setupBasicPage() { | ||
document.body.innerHTML = ` | ||
<nav>Nav Text</nav> | ||
<section> | ||
<h1>First Section Heading</h1> | ||
<p>First Section Text</p> | ||
<article> | ||
<header> | ||
<h1>Article Header Heading</h1> | ||
<p>Article Header Text</p> | ||
</header> | ||
<p>Article Text</p> | ||
</article> | ||
</section> | ||
<section> | ||
<h1>Second Section Heading</h1> | ||
<p>Second Section Text</p> | ||
</section> | ||
<section aria-hidden="true"> | ||
<h1>Hidden Section Heading</h1> | ||
<p>Hidden Section Text</p> | ||
</section> | ||
<footer>Footer</footer> | ||
`; | ||
} | ||
|
||
describe("matchers", () => { | ||
beforeEach(() => { | ||
setupBasicPage(); | ||
}); | ||
|
||
afterEach(() => { | ||
document.body.innerHTML = ``; | ||
}); | ||
|
||
describe("virtual screen reader tests", () => { | ||
test("navigating headings", async () => { | ||
await virtual.start({ container: document.body }); | ||
|
||
await virtual.perform(virtual.commands.moveToNextHeading); | ||
const firstHeadingPhrase = await virtual.lastSpokenPhrase(); | ||
|
||
do { | ||
await virtual.perform(virtual.commands.moveToNextHeading); | ||
} while ((await virtual.lastSpokenPhrase()) !== firstHeadingPhrase); | ||
|
||
expect(await virtual.spokenPhraseLog()).toMatchSnapshot(); | ||
|
||
await virtual.stop(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.