@allwright.dev/vitest 0.1.22 → 0.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @allwright.dev/vitest
2
2
 
3
3
  Vitest fixtures for allwright with Playwright-style `browser` and `page`
4
- injection, plus Android, iOS, and macOS app fixtures for native and hybrid tests.
4
+ injection, plus Android, iOS, macOS, and Windows app fixtures for native and hybrid tests.
5
5
 
6
6
  Wrap the Vitest configuration with `allwrightVitestConfig`. It starts Allwright once before workers run and shuts it down once after the complete test run. Existing user global setup files remain supported and run after Allwright starts, then tear down before Allwright stops.
7
7
 
@@ -44,10 +44,19 @@ test("opens an iOS app", async ({ iosApp }) => {
44
44
  test("opens a macOS app", async ({ macosApp }) => {
45
45
  await macosApp.getByRole("button", { name: "New Document", exact: true }).click();
46
46
  });
47
+
48
+ test("opens a Windows app", async ({ windowsApp }) => {
49
+ await windowsApp.getByRole("textbox").fill("Hello from Allwright");
50
+ });
47
51
  ```
48
52
 
49
- Checked-in example specs live in [examples/basic.spec.ts](./examples/basic.spec.ts)
50
- and [examples/ios-flights.spec.ts](./examples/ios-flights.spec.ts).
53
+ Checked-in example specs cover every implemented surface:
54
+ [Web](./examples/basic.spec.ts), [Android](./examples/android-flights.spec.ts),
55
+ [iOS](./examples/ios-flights.spec.ts),
56
+ [macOS](./examples/macos-calculator.spec.ts), and
57
+ [Windows](./examples/windows-notepad.spec.ts). Native specs use the app target
58
+ configured for their surface in `allwright.config.yaml` or
59
+ `allwright.config.json`.
51
60
 
52
61
  The fixture package reads the shared stack-agnostic config format through `@allwright.dev/core`.
53
62
  Use `allwright.config.yaml` by default, or `allwright.config.json` if you prefer. Both follow the same root schema in `allwright.schema.json`.
@@ -167,11 +176,35 @@ test("opens a document window", async ({ macosApp }) => {
167
176
  Use `ALLWRIGHT_MAC_AGENT_ENDPOINT` for an external agent or
168
177
  `ALLWRIGHT_MAC_APP_ID` to override the configured bundle identifier.
169
178
 
179
+ Windows apps use an executable path, command name, or packaged-app AUMID. The
180
+ fixture starts the bundled FlaUI UIA3 agent and launches the app lazily:
181
+
182
+ ```yaml
183
+ # allwright.config.yaml
184
+ desktop:
185
+ windows:
186
+ app:
187
+ id: notepad.exe
188
+ ```
189
+
190
+ ```ts
191
+ import { expect, test } from "@allwright.dev/vitest";
192
+
193
+ test("edits a document", async ({ windowsApp }) => {
194
+ await windowsApp.getByRole("textbox").fill("Hello from Allwright");
195
+ await expect(windowsApp.getByRole("textbox")).toContainText("Hello");
196
+ });
197
+ ```
198
+
199
+ Use `ALLWRIGHT_WINDOWS_AGENT_ENDPOINT` for an external agent or
200
+ `ALLWRIGHT_WINDOWS_APP_ID` to override the configured application identifier.
201
+
170
202
  Fixtures are lazy on first use. Injecting `browser`, `page`, `android`,
171
- `androidApp`, `ios`, `iosApp`, `macos`, or `macosApp` does not launch or connect
172
- immediately; the underlying session is created only when the test first
173
- performs an action through that fixture. Sync metadata properties are only
174
- available after the lazy fixture has been realized by a prior awaited call.
203
+ `androidApp`, `ios`, `iosApp`, `macos`, `macosApp`, `windows`, or `windowsApp`
204
+ does not launch or connect immediately; the underlying session is created only
205
+ when the test first performs an action through that fixture. Sync metadata
206
+ properties are only available after the lazy fixture has been realized by a
207
+ prior awaited call.
175
208
 
176
209
  Available fixtures:
177
210
 
@@ -183,13 +216,16 @@ Available fixtures:
183
216
  - `iosApp`: launched iOS app page
184
217
  - `macos`: connected macOS desktop session
185
218
  - `macosApp`: launched macOS app page
219
+ - `windows`: connected Windows desktop session
220
+ - `windowsApp`: launched Windows app page
186
221
 
187
222
  `androidApp` launches using `allwright.android.launchOptions` first, then falls back to `config.mobile.android`.
188
223
  `iosApp` does the same with `allwright.ios.launchOptions` and `config.mobile.ios`.
189
224
  `macosApp` does the same with `allwright.macos.launchOptions` and `config.desktop.mac`.
225
+ `windowsApp` does the same with `allwright.windows.launchOptions` and `config.desktop.windows`.
190
226
 
191
- Android, iOS, and macOS apps and locators support the native action and expectation
192
- subset: `click`, `count`, `focus`, `fill`, `press`, `textContent`, `innerText`,
227
+ Android, iOS, macOS, and Windows apps and locators support the native action and
228
+ expectation subset: `click`, `count`, `focus`, `fill`, `press`, `textContent`, `innerText`,
193
229
  `waitForSelector`, and `screenshot`. Mobile expectations provide `toHaveText`,
194
230
  `toContainText`, `toHaveCount`, and `toBeVisible` with the same retry controls
195
231
  as web fixtures. Hover and highlight remain web-only.
@@ -1,4 +1,4 @@
1
- import type { BoundingBox, CommandOptions, Locator, MobileAndroidApp, MobileAndroidLocator, Page, WaitForSelectorOptions } from "@allwright.dev/core";
1
+ import type { BoundingBox, CommandOptions, Locator, NativeApp, NativeAppLocator, Page, WaitForSelectorOptions } from "@allwright.dev/core";
2
2
  export interface RetryExpectationOptions {
3
3
  timeoutMs?: number;
4
4
  intervalMs?: number;
@@ -48,11 +48,11 @@ export interface PageExpectMatchers extends MobilePageExpectMatchers {
48
48
  toHaveBoundingBox(selector: string, expected: Partial<BoundingBox> | null, options?: TextExpectationOptions): Promise<void>;
49
49
  }
50
50
  type Defaults = () => RetryExpectationOptions;
51
- type AnyLocator = Locator | MobileAndroidLocator;
51
+ type AnyLocator = Locator | NativeAppLocator;
52
52
  export declare function createLocatorExpect(locator: Locator, defaults: Defaults, negated?: boolean): LocatorExpectMatchers;
53
- export declare function createLocatorExpect(locator: MobileAndroidLocator, defaults: Defaults, negated?: boolean): MobileLocatorExpectMatchers;
53
+ export declare function createLocatorExpect(locator: NativeAppLocator, defaults: Defaults, negated?: boolean): MobileLocatorExpectMatchers;
54
54
  export declare function createLocatorExpect(locator: AnyLocator, defaults: Defaults, negated?: boolean): MobileLocatorExpectMatchers;
55
55
  export declare function createPageExpect(page: Page, defaults: Defaults, negated?: boolean): PageExpectMatchers;
56
- export declare function createPageExpect(page: MobileAndroidApp, defaults: Defaults, negated?: boolean): MobilePageExpectMatchers;
57
- export declare function createPageExpect(page: Page | MobileAndroidApp, defaults: Defaults, negated?: boolean): MobilePageExpectMatchers;
56
+ export declare function createPageExpect(page: NativeApp, defaults: Defaults, negated?: boolean): MobilePageExpectMatchers;
57
+ export declare function createPageExpect(page: Page | NativeApp, defaults: Defaults, negated?: boolean): MobilePageExpectMatchers;
58
58
  export {};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { PageExpectMatchers, LocatorExpectMatchers, MobilePageExpectMatchers, MobileLocatorExpectMatchers } from "./expectations.js";
2
2
  export type { RetryExpectationOptions, TextExpectationOptions, VisibleExpectationOptions, SelectedOptionExpectation, PageExpectMatchers, LocatorExpectMatchers, MobilePageExpectMatchers, MobileLocatorExpectMatchers } from "./expectations.js";
3
- import { type MobileAndroidConnectOptions, type MobileAndroidDevice, type MobileAndroidLaunchOptions, type MobileAndroidApp, type MobileIosConnectOptions, type MobileIosDevice, type MobileIosLaunchOptions, type MobileIosApp, type DesktopMacApp, type DesktopMacConnectOptions, type DesktopMacDesktop, type DesktopMacLaunchOptions, type Browser, type BrowserKind, type LaunchOptions, type Locator, type MobileAndroidLocator, type Page } from "@allwright.dev/core";
3
+ import { type MobileAndroidConnectOptions, type MobileAndroidDevice, type MobileAndroidLaunchOptions, type MobileAndroidApp, type NativeApp, type NativeAppLocator, type MobileIosConnectOptions, type MobileIosDevice, type MobileIosLaunchOptions, type MobileIosApp, type DesktopMacApp, type DesktopMacConnectOptions, type DesktopMacDesktop, type DesktopMacLaunchOptions, type DesktopWindowsApp, type DesktopWindowsConnectOptions, type DesktopWindowsDesktop, type DesktopWindowsLaunchOptions, type Browser, type BrowserKind, type LaunchOptions, type Locator, type Page } from "@allwright.dev/core";
4
4
  import { expect as vitestExpect, type Assertion } from "vitest";
5
5
  export interface AllwrightVitestOptions {
6
6
  launchOptions?: LaunchOptions;
@@ -19,6 +19,10 @@ export interface AllwrightVitestOptions {
19
19
  connectOptions?: DesktopMacConnectOptions;
20
20
  launchOptions?: DesktopMacLaunchOptions;
21
21
  };
22
+ windows?: {
23
+ connectOptions?: DesktopWindowsConnectOptions;
24
+ launchOptions?: DesktopWindowsLaunchOptions;
25
+ };
22
26
  configFile?: string;
23
27
  suite?: string;
24
28
  }
@@ -31,6 +35,8 @@ export interface AllwrightVitestFixtures {
31
35
  iosApp: MobileIosApp;
32
36
  macos: DesktopMacDesktop;
33
37
  macosApp: DesktopMacApp;
38
+ windows: DesktopWindowsDesktop;
39
+ windowsApp: DesktopWindowsApp;
34
40
  }
35
41
  interface LazyResource<T> {
36
42
  peek(): T | null;
@@ -41,23 +47,26 @@ export declare const test: import("vitest").TestAPI<{
41
47
  browser: Browser;
42
48
  page: Page;
43
49
  android: MobileAndroidDevice;
44
- androidApp: MobileAndroidApp;
50
+ androidApp: NativeApp;
45
51
  ios: MobileIosDevice;
46
- iosApp: MobileAndroidApp;
52
+ iosApp: NativeApp;
47
53
  macos: DesktopMacDesktop;
48
- macosApp: MobileAndroidApp;
54
+ macosApp: NativeApp;
55
+ windows: DesktopWindowsDesktop;
56
+ windowsApp: NativeApp;
49
57
  allwright: AllwrightVitestOptions;
50
58
  _browserResource: LazyResource<Browser>;
51
59
  _androidResource: LazyResource<MobileAndroidDevice>;
52
60
  _iosResource: LazyResource<MobileIosDevice>;
53
61
  _macosResource: LazyResource<DesktopMacDesktop>;
62
+ _windowsResource: LazyResource<DesktopWindowsDesktop>;
54
63
  }>;
55
64
  type VitestExpect = typeof vitestExpect;
56
65
  interface AllwrightExpect extends VitestExpect {
57
66
  (actual: Page): PageExpectMatchers;
58
67
  (actual: Locator): LocatorExpectMatchers;
59
- (actual: MobileAndroidApp): MobilePageExpectMatchers;
60
- (actual: MobileAndroidLocator): MobileLocatorExpectMatchers;
68
+ (actual: NativeApp): MobilePageExpectMatchers;
69
+ (actual: NativeAppLocator): MobileLocatorExpectMatchers;
61
70
  <T>(actual: T): Assertion<T>;
62
71
  }
63
72
  export declare const expect: AllwrightExpect;
package/dist/index.js CHANGED
@@ -7,6 +7,8 @@ const DEFAULT_IOS_CONNECT_TIMEOUT_MS = 30_000;
7
7
  const DEFAULT_IOS_LAUNCH_TIMEOUT_MS = 60_000;
8
8
  const DEFAULT_MACOS_CONNECT_TIMEOUT_MS = 30_000;
9
9
  const DEFAULT_MACOS_LAUNCH_TIMEOUT_MS = 60_000;
10
+ const DEFAULT_WINDOWS_CONNECT_TIMEOUT_MS = 30_000;
11
+ const DEFAULT_WINDOWS_LAUNCH_TIMEOUT_MS = 60_000;
10
12
  function createLazyResource(factory) {
11
13
  let value = null;
12
14
  let promise = null;
@@ -495,6 +497,20 @@ function createLazyMacosDesktop(desktopResource) {
495
497
  },
496
498
  };
497
499
  }
500
+ function createLazyWindowsDesktop(desktopResource) {
501
+ const initialAppResource = createLazyResource(async () => (await desktopResource.get()).app());
502
+ return {
503
+ get sessionId() {
504
+ return getLazySyncProperty(desktopResource, "sessionId");
505
+ },
506
+ app() {
507
+ return createLazyMobileApp(initialAppResource);
508
+ },
509
+ async launch(options) {
510
+ return (await desktopResource.get()).launch(options);
511
+ },
512
+ };
513
+ }
498
514
  export const test = base.extend({
499
515
  allwright: async ({}, use) => {
500
516
  await use({});
@@ -540,6 +556,14 @@ export const test = base.extend({
540
556
  const macosResource = createLazyResource(async () => desktop.mac.connect(resolveMacosConnectOptions(config, allwright)));
541
557
  await use(macosResource);
542
558
  },
559
+ _windowsResource: async ({ allwright }, use) => {
560
+ const config = resolveVitestConfig(allwright);
561
+ if (config.serverAddr) {
562
+ setServerAddr(config.serverAddr);
563
+ }
564
+ const windowsResource = createLazyResource(async () => desktop.windows.connect(resolveWindowsConnectOptions(config, allwright)));
565
+ await use(windowsResource);
566
+ },
543
567
  browser: async ({ _browserResource }, use) => {
544
568
  try {
545
569
  await use(createLazyBrowser(_browserResource));
@@ -584,6 +608,17 @@ export const test = base.extend({
584
608
  });
585
609
  await use(createLazyMobileApp(appResource));
586
610
  },
611
+ windows: async ({ _windowsResource }, use) => {
612
+ await use(createLazyWindowsDesktop(_windowsResource));
613
+ },
614
+ windowsApp: async ({ _windowsResource, allwright }, use) => {
615
+ const appResource = createLazyResource(async () => {
616
+ const config = resolveVitestConfig(allwright);
617
+ const launchOptions = resolveWindowsLaunchOptions(config, allwright);
618
+ return (await _windowsResource.get()).launch(launchOptions);
619
+ });
620
+ await use(createLazyMobileApp(appResource));
621
+ },
587
622
  });
588
623
  function isPage(value) {
589
624
  return !!value && typeof value === "object" && typeof value.locator === "function";
@@ -689,6 +724,28 @@ function resolveMacosLaunchOptions(config, options) {
689
724
  DEFAULT_MACOS_LAUNCH_TIMEOUT_MS,
690
725
  };
691
726
  }
727
+ function resolveWindowsConnectOptions(config, options) {
728
+ return {
729
+ agentEndpoint: options.windows?.connectOptions?.agentEndpoint ??
730
+ process.env.ALLWRIGHT_WINDOWS_AGENT_ENDPOINT,
731
+ timeoutMs: options.windows?.connectOptions?.timeoutMs ??
732
+ DEFAULT_WINDOWS_CONNECT_TIMEOUT_MS,
733
+ };
734
+ }
735
+ function resolveWindowsLaunchOptions(config, options) {
736
+ const appId = options.windows?.launchOptions?.appId ??
737
+ process.env.ALLWRIGHT_WINDOWS_APP_ID ??
738
+ config.desktop.windows?.appId;
739
+ if (!appId) {
740
+ throw new Error("windowsApp fixture requires Windows launch options with `appId`, or config.desktop.windows.app configured");
741
+ }
742
+ return {
743
+ appId,
744
+ terminateRunning: options.windows?.launchOptions?.terminateRunning ?? false,
745
+ timeoutMs: options.windows?.launchOptions?.timeoutMs ??
746
+ DEFAULT_WINDOWS_LAUNCH_TIMEOUT_MS,
747
+ };
748
+ }
692
749
  let activeExpectDefaults = {};
693
750
  function currentExpectDefaults() {
694
751
  return activeExpectDefaults;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allwright.dev/vitest",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "description": "Vitest fixtures for the allwright TypeScript client.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -47,7 +47,7 @@
47
47
  "prepublishOnly": "bun run build"
48
48
  },
49
49
  "dependencies": {
50
- "@allwright.dev/core": "0.1.22"
50
+ "@allwright.dev/core": "0.1.24"
51
51
  },
52
52
  "devDependencies": {
53
53
  "typescript": "^5.9.2",