Skip to content

Commit 7ddd0d2

Browse files
feat: allow setting of start options (#17)
1 parent 7632467 commit 7ddd0d2

File tree

9 files changed

+57
-7
lines changed

9 files changed

+57
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,4 @@ dist
106106
lib
107107
.DS_Store
108108
test-results
109+
recordings

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,30 @@ await nvda.navigateToWebContent();
110110
111111
// ... some commands
112112
113-
// Collect all spoken phrasees
113+
// Collect all spoken phrases
114114
const allSpokenPhrases = [...spokenPhrases, ...(await nvda.spokenPhraseLog())];
115115
116116
// ... do something with spoken phrases
117117
```
118118

119+
### Providing Screen Reader Start Options
120+
121+
The options provided to `nvda.start([options])` or `voiceOver.start([options])` can be configured using `test.use(config)` as follows:
122+
123+
```ts
124+
// VoiceOver Example
125+
import { voiceOverTest as test } from "@guidepup/playwright";
126+
127+
test.use({ voiceOverStartOptions: { capture: "initial" } });
128+
```
129+
130+
```ts
131+
// NVDA Example
132+
import { nvdaTest as test } from "@guidepup/playwright";
133+
134+
test.use({ nvdaStartOptions: { capture: "initial" } });
135+
```
136+
119137
### VoiceOver Example
120138

121139
`playwright.config.ts`:

examples/playwright-nvda/tests/chromium/chromium.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { windowsRecord } from "@guidepup/guidepup";
55
import spokenPhraseSnapshot from "./chromium.spokenPhrase.snapshot.json";
66
import { nvdaTest as test } from "../../../../src";
77

8+
test.use({ nvdaStartOptions: { capture: "initial" } });
9+
810
test.describe("Chromium Playwright NVDA", () => {
911
test("I can navigate the Guidepup Github page", async ({
1012
browser,

examples/playwright-nvda/tests/firefox/firefox.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { windowsRecord } from "@guidepup/guidepup";
55
import spokenPhraseSnapshot from "./firefox.spokenPhrase.snapshot.json";
66
import { nvdaTest as test } from "../../../../src";
77

8+
test.use({ nvdaStartOptions: { capture: "initial" } });
9+
810
test.describe("Firefox Playwright VoiceOver", () => {
911
test("I can navigate the Guidepup Github page", async ({
1012
browser,

examples/playwright-voiceover/tests/chromium/chromium.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { macOSRecord } from "@guidepup/guidepup";
66
import spokenPhraseSnapshot from "./chromium.spokenPhrase.snapshot.json";
77
import { voiceOverTest as test } from "../../../../src";
88

9+
test.use({ voiceOverStartOptions: { capture: "initial" } });
10+
911
test.describe("Chromium Playwright VoiceOver", () => {
1012
test("I can navigate the Guidepup Github page", async ({
1113
browser,

examples/playwright-voiceover/tests/firefox/firefox.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { macOSRecord } from "@guidepup/guidepup";
66
import spokenPhraseSnapshot from "./firefox.spokenPhrase.snapshot.json";
77
import { voiceOverTest as test } from "../../../../src";
88

9+
test.use({ voiceOverStartOptions: { capture: "initial" } });
10+
911
test.describe("Firefox Playwright VoiceOver", () => {
1012
test("I can navigate the Guidepup Github page", async ({
1113
browser,

examples/playwright-voiceover/tests/webkit/webkit.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { macOSRecord } from "@guidepup/guidepup";
66
import spokenPhraseSnapshot from "./webkit.spokenPhrase.snapshot.json";
77
import { voiceOverTest as test } from "../../../../src";
88

9+
test.use({ voiceOverStartOptions: { capture: "initial" } });
10+
911
test.describe("Webkit Playwright VoiceOver", () => {
1012
test("I can navigate the Guidepup Github page", async ({
1113
browser,

src/nvdaTest.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import { test } from "@playwright/test";
22
import { nvda, WindowsKeyCodes, WindowsModifiers } from "@guidepup/guidepup";
3-
import type { NVDA } from "@guidepup/guidepup";
3+
import type { CommandOptions, NVDA } from "@guidepup/guidepup";
44
import { applicationNameMap } from "./applicationNameMap";
55

6+
type Prettify<T> = {
7+
[K in keyof T]: T[K];
8+
// eslint-disable-next-line @typescript-eslint/ban-types
9+
} & {};
10+
11+
type CaptureCommandOptions = Prettify<Pick<CommandOptions, "capture">>;
12+
613
/**
714
* [API Reference](https://www.guidepup.dev/docs/api/class-nvda)
815
*
@@ -108,8 +115,15 @@ export const nvdaTest = test.extend<{
108115
* ```
109116
*/
110117
nvda: NVDAPlaywright;
118+
/**
119+
* [API Reference](https://www.guidepup.dev/docs/api/class-command-options)
120+
*
121+
* Options to start NVDA with, see also [nvda.start([options])](https://www.guidepup.dev/docs/api/class-nvda#nvda-start).
122+
*/
123+
nvdaStartOptions: CaptureCommandOptions;
111124
}>({
112-
nvda: async ({ browserName, page }, use) => {
125+
nvdaStartOptions: {},
126+
nvda: async ({ browserName, page, nvdaStartOptions }, use) => {
113127
try {
114128
const applicationName = applicationNameMap[browserName];
115129

@@ -158,7 +172,7 @@ export const nvdaTest = test.extend<{
158172
await nvdaPlaywright.clearSpokenPhraseLog();
159173
};
160174

161-
await nvdaPlaywright.start();
175+
await nvdaPlaywright.start(nvdaStartOptions);
162176

163177
await use(nvdaPlaywright);
164178
} finally {

src/voiceOverTest.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test } from "@playwright/test";
22
import { voiceOver, macOSActivate } from "@guidepup/guidepup";
3-
import type { VoiceOver } from "@guidepup/guidepup";
3+
import type { CommandOptions, VoiceOver } from "@guidepup/guidepup";
44
import { applicationNameMap } from "./applicationNameMap";
55

66
/**
@@ -74,8 +74,15 @@ export const voiceOverTest = test.extend<{
7474
* ```
7575
*/
7676
voiceOver: VoiceOverPlaywright;
77+
/**
78+
* [API Reference](https://www.guidepup.dev/docs/api/class-command-options)
79+
*
80+
* Options to start VoiceOver with, see also [voiceOver.start([options])](https://www.guidepup.dev/docs/api/class-voiceover#voiceover-start).
81+
*/
82+
voiceOverStartOptions: CommandOptions;
7783
}>({
78-
voiceOver: async ({ browserName, page }, use) => {
84+
voiceOverStartOptions: {},
85+
voiceOver: async ({ browserName, page, voiceOverStartOptions }, use) => {
7986
try {
8087
const applicationName = applicationNameMap[browserName];
8188

@@ -103,7 +110,7 @@ export const voiceOverTest = test.extend<{
103110
await voiceOverPlaywright.clearSpokenPhraseLog();
104111
};
105112

106-
await voiceOverPlaywright.start();
113+
await voiceOverPlaywright.start(voiceOverStartOptions);
107114
await macOSActivate(applicationName);
108115
await use(voiceOverPlaywright);
109116
} finally {

0 commit comments

Comments
 (0)