-
-
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.
fix: support ESM and add web-test-runner example (#56)
- Loading branch information
1 parent
57e9296
commit 3153be7
Showing
33 changed files
with
2,855 additions
and
419 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
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
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
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,19 @@ | ||
{ | ||
"name": "@guidepup/virtual-screen-reader-web-test-runner-example", | ||
"version": "0.0.0", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"pretest": "yarn --cwd=../.. build", | ||
"test": "web-test-runner \"test/**/*.test.js\"", | ||
"test:watch": "yarn test --watch" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@esm-bundle/chai": "4.3.4", | ||
"@rollup/plugin-commonjs": "^25.0.7", | ||
"@rollup/plugin-replace": "^5.0.5", | ||
"@web/dev-server-rollup": "^0.6.1", | ||
"@web/test-runner": "^0.18.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,39 @@ | ||
import { expect } from "@esm-bundle/chai"; | ||
|
||
/** | ||
* Replace with: | ||
* | ||
* import { virtual } from '@guidepup/virtual-screen-reader' | ||
* | ||
* in your own code. | ||
*/ | ||
import { virtual } from "../../../lib/esm/index.js"; | ||
|
||
beforeEach(async () => { | ||
document.body.innerHTML = "<h1>Heading</h1><p>Paragraph text</p>"; | ||
|
||
await virtual.start({ container: document.body }); | ||
}); | ||
|
||
afterEach(async () => { | ||
await virtual.stop(); | ||
|
||
document.body.innerHTML = ""; | ||
}); | ||
|
||
it("renders a heading and a paragraph", async () => { | ||
await virtual.next(); | ||
await virtual.next(); | ||
await virtual.next(); | ||
await virtual.next(); | ||
await virtual.next(); | ||
|
||
expect(await virtual.spokenPhraseLog()).to.eql([ | ||
"document", | ||
"heading, Heading, level 1", | ||
"paragraph", | ||
"Paragraph text", | ||
"end of paragraph", | ||
"end of document", | ||
]); | ||
}); |
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,30 @@ | ||
import _commonjs from "@rollup/plugin-commonjs"; | ||
import _replace from "@rollup/plugin-replace"; | ||
import { fromRollup } from "@web/dev-server-rollup"; | ||
|
||
const commonjs = fromRollup(_commonjs); | ||
const replace = fromRollup(_replace); | ||
|
||
export default { | ||
nodeResolve: true, | ||
plugins: [ | ||
// Support @testing-library/dom usage of module that checks if running in | ||
// production or development. | ||
// See `node_modules/@testing-library/dom/node_modules/react-is/cjs/react-is.development.js` | ||
replace({ | ||
"process.env.NODE_ENV": JSON.stringify("production"), | ||
preventAssignment: true, | ||
}), | ||
// Handle dependencies that are commonjs only and need compiling to support | ||
// an ESM environment. | ||
commonjs({ | ||
include: [ | ||
"**/node_modules/@testing-library/**", | ||
"**/node_modules/ansi-regex/**", | ||
"**/node_modules/aria-query/**", | ||
"**/node_modules/dequal/**", | ||
"**/node_modules/lz-string/**", | ||
], | ||
}), | ||
], | ||
}; |
Oops, something went wrong.