test: Add basic tests for screenreader output #784
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds infrastructure for writing screenreader tests using Guidepup. This is quite experimental and a bit temperamental, but having the ability to at least make some assertions about screenreader behavior seems valuable nonetheless.
Requirements
Currently this test setup only supports Chrome and VoiceOver on macOS. It should be relatively straightforward to extend it to support Chrome and NVDA on Windows. Other browsers on both platforms are probably possible as well, but more involved; Guidepup is not tied to Chrome in any way, but our existing test infrastructure which this PR reuses is.
You'll need to complete the Local Setup portion of this guide; Guidepup also offers a tool that may automate some of this, but I haven't tried it. The CI setup portion of the guide is not necessary, nor anything under the Additional System Permissions section. The first time(s) you run the test suite you may be bombarded by various approval dialogs which should be granted.
Running the tests
Once your system is set up, you should just be able to do
npm run test:screenreader.For best results:
psand I suspect is there to verify that AppleScript automation of VoiceOver has been enabled, but AFAICT is unnecessary; commenting outconst appleScriptRunning...in node_modules/@guidepup/guidepup/lib/macOS/VoiceOver/isRunning.js makes running the tests much less flaky.Writing tests
voiceOver.press('key goes here')rather than our navigation utilities.assert.include()rather than a strict comparison of the screenreader output is helpful, as depending on context VoiceOver sometimes faffs around and includes instructions or other unrelated output.