https://github.com/phenomnomnominal/screen-reader-reader
A general purpose screen reader reader
https://github.com/phenomnomnominal/screen-reader-reader
Last synced: 14 days ago
JSON representation
A general purpose screen reader reader
- Host: GitHub
- URL: https://github.com/phenomnomnominal/screen-reader-reader
- Owner: phenomnomnominal
- License: mit
- Created: 2019-10-28T23:22:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T23:39:14.000Z (over 2 years ago)
- Last Synced: 2025-04-26T16:46:09.539Z (23 days ago)
- Language: TypeScript
- Size: 775 KB
- Stars: 57
- Watchers: 5
- Forks: 3
- Open Issues: 17
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# screen-reader-reader
[](https://img.shields.io/npm/v/screen-reader-reader.svg)
This is a very experimental attempt at creating a general purpose screen reader reader, with the aim of enabling more realistic end-to-end accessibility tests!
The goal would be to have something like this:
```ts
describe('my website', () => {
it(`should have correct screen reader output`, async () => {
await page.goto('https://www.my-website.com');const result = await startScreenReader({
waitForStable: true
});expect(result).toMatchSnapshot();
});
});
```This is _very_ much a work in progress! I would love your help to make this more stable!
## Currently working
- Turning on VoiceOver (Mac OS), reading VoiceOver output as text, turning off VoiceOver.
- Turning on [NVDA](https://www.nvaccess.org/) (Windows), reading NVDA output as text, turning off NVDA.## Goals
- More stability. There is some unexpected behaviour when running the tests with Puppeteer that I'm sure people with more screen reader experience will be able to explain.
- More screen readers. It would be good to get this working with [JAWS](https://www.freedomscientific.com/products/software/jaws/) and other commonly used screen readers.
- Other things?## Installation
```sh
npm install screen-reader-reader --save-dev
```## Usage
### CLI
There is a very basic CLI. It will enable the given screen reader (or automatically detect one), and read the screen reader output until it is stable.
```sh
npx screen-reader-reader
```### JavaScript
#### Import
```js
import { startScreenReader } from 'screen-reader-reader';
```When using the API from JavaScript, there are two distinct modes:
#### Stable mode
```js
const result = await startScreenReader({
waitForStable: true
});console.log(result);
```#### Manual mode
```js
const stop = await startScreenReader();// Do whatever you want to do...
const result = await stop();
```#### Options
The `startScreenReader` function takes a number of options:
```ts
type Options = {
screenreader: ScreenReaderName; // Default = from local environment
pollTimeout: number; // Default = 100ms
stableTimeout: number; // Default = 10000ms
waitForStable: boolean; // Default = false
filters: Array; // Default = []
mappers: Array<(t: string) => string>; // Default = []
};const enum ScreenReaderName {
voiceover,
nvda
}
```