spana-test 0.0.2 → 0.1.0

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.
Files changed (105) hide show
  1. package/.agents/skills/spana-testing/SKILL.md +301 -0
  2. package/README.md +33 -4
  3. package/dist/agent/index.d.ts +81 -0
  4. package/dist/agent/index.js +21 -0
  5. package/dist/allure-PTTVORQ6.js +124 -0
  6. package/dist/allure-PTTVORQ6.js.map +1 -0
  7. package/dist/android-PAPJJWVN.js +34 -0
  8. package/dist/android-PAPJJWVN.js.map +1 -0
  9. package/dist/chunk-3FSZNKEF.js +62 -0
  10. package/dist/chunk-3FSZNKEF.js.map +1 -0
  11. package/dist/chunk-53MUJUJY.js +113 -0
  12. package/dist/chunk-53MUJUJY.js.map +1 -0
  13. package/dist/chunk-5XO6S7AI.js +134 -0
  14. package/dist/chunk-5XO6S7AI.js.map +1 -0
  15. package/dist/chunk-BZRLA4Z3.js +82 -0
  16. package/dist/chunk-BZRLA4Z3.js.map +1 -0
  17. package/dist/{chunk-VZZH66U5.js → chunk-CKJQX73M.js} +896 -844
  18. package/dist/chunk-CKJQX73M.js.map +1 -0
  19. package/dist/chunk-DGUM43GV.js +11 -0
  20. package/dist/chunk-DGUM43GV.js.map +1 -0
  21. package/dist/{chunk-CYEDLQJ4.js → chunk-GZK22EIE.js} +76 -102
  22. package/dist/chunk-GZK22EIE.js.map +1 -0
  23. package/dist/chunk-PANFRTIU.js +310 -0
  24. package/dist/chunk-PANFRTIU.js.map +1 -0
  25. package/dist/chunk-PWEOJKUF.js +473 -0
  26. package/dist/chunk-PWEOJKUF.js.map +1 -0
  27. package/dist/chunk-RJ5VPHVX.js +127 -0
  28. package/dist/chunk-RJ5VPHVX.js.map +1 -0
  29. package/dist/chunk-RK4Z6C7M.js +248 -0
  30. package/dist/chunk-RK4Z6C7M.js.map +1 -0
  31. package/dist/chunk-U564GCO2.js +259 -0
  32. package/dist/chunk-U564GCO2.js.map +1 -0
  33. package/dist/chunk-V62HFH6E.js +269 -0
  34. package/dist/chunk-V62HFH6E.js.map +1 -0
  35. package/dist/chunk-VDWWIVM6.js +303 -0
  36. package/dist/chunk-VDWWIVM6.js.map +1 -0
  37. package/dist/{discover-XIRJTZ7Z.js → chunk-WIJYK22K.js} +12 -5
  38. package/dist/{discover-XIRJTZ7Z.js.map → chunk-WIJYK22K.js.map} +1 -1
  39. package/dist/cli.js +134 -16
  40. package/dist/cli.js.map +1 -1
  41. package/dist/compiler-G75RIIYS.js +312 -0
  42. package/dist/compiler-G75RIIYS.js.map +1 -0
  43. package/dist/config-Dg9O0rcQ.d.ts +219 -0
  44. package/dist/config-loader-JJ5RPP53.js +9 -0
  45. package/dist/config-loader-JJ5RPP53.js.map +1 -0
  46. package/dist/console-FV4RJPO4.js +132 -0
  47. package/dist/console-FV4RJPO4.js.map +1 -0
  48. package/dist/discover-RWBKI5IB.js +14 -0
  49. package/dist/discover-RWBKI5IB.js.map +1 -0
  50. package/dist/element-CGteXiXB.d.ts +23 -0
  51. package/dist/flow-D-_tlLpp.d.ts +99 -0
  52. package/dist/gherkin/steps.d.ts +32 -0
  53. package/dist/gherkin/steps.js +39 -0
  54. package/dist/gherkin/steps.js.map +1 -0
  55. package/dist/{html-GRB34S6X.js → html-JP2HBIJQ.js} +54 -20
  56. package/dist/html-JP2HBIJQ.js.map +1 -0
  57. package/dist/index.d.ts +4 -157
  58. package/dist/index.js +36 -165
  59. package/dist/index.js.map +1 -1
  60. package/dist/init-command-CELKL2CX.js +105 -0
  61. package/dist/init-command-CELKL2CX.js.map +1 -0
  62. package/dist/installer-R6NX7BYQ.js +20 -0
  63. package/dist/installer-R6NX7BYQ.js.map +1 -0
  64. package/dist/ios-ZZU6DHH7.js +48 -0
  65. package/dist/ios-ZZU6DHH7.js.map +1 -0
  66. package/dist/{json-FK2NSRGC.js → json-JMRPUVY2.js} +2 -2
  67. package/dist/{junit-NAGZJOGQ.js → junit-UDY5JG22.js} +14 -3
  68. package/dist/junit-UDY5JG22.js.map +1 -0
  69. package/dist/provider-CUWPULGC.js +10 -0
  70. package/dist/provider-CUWPULGC.js.map +1 -0
  71. package/dist/redact-IDA3C4UH.js +77 -0
  72. package/dist/redact-IDA3C4UH.js.map +1 -0
  73. package/dist/runner-QEF6PJOE.js +20 -0
  74. package/dist/runner-QEF6PJOE.js.map +1 -0
  75. package/dist/server-MMK7PZIH.js +505 -0
  76. package/dist/server-MMK7PZIH.js.map +1 -0
  77. package/dist/session-FBJABNXL.js +16 -0
  78. package/dist/session-FBJABNXL.js.map +1 -0
  79. package/dist/studio-command-CDVPREMG.js +24 -0
  80. package/dist/studio-command-CDVPREMG.js.map +1 -0
  81. package/dist/test-command-SB5KYPQI.js +1929 -0
  82. package/dist/test-command-SB5KYPQI.js.map +1 -0
  83. package/dist/validator-CFQ55NUQ.js +13 -0
  84. package/dist/validator-CFQ55NUQ.js.map +1 -0
  85. package/package.json +41 -4
  86. package/studio-dist/assets/index-CPdpC9i-.css +1 -0
  87. package/studio-dist/assets/index-L1Wd0vop.js +183 -0
  88. package/studio-dist/index.html +13 -0
  89. package/dist/chunk-CYEDLQJ4.js.map +0 -1
  90. package/dist/chunk-PVNNKPBW.js +0 -64
  91. package/dist/chunk-PVNNKPBW.js.map +0 -1
  92. package/dist/chunk-VZZH66U5.js.map +0 -1
  93. package/dist/console-GPV3M3PC.js +0 -71
  94. package/dist/console-GPV3M3PC.js.map +0 -1
  95. package/dist/html-GRB34S6X.js.map +0 -1
  96. package/dist/junit-NAGZJOGQ.js.map +0 -1
  97. package/dist/runner-LBQUCG3K.js +0 -12
  98. package/dist/session-U7VP5J2C.js +0 -122
  99. package/dist/session-U7VP5J2C.js.map +0 -1
  100. package/dist/test-command-WPYLJYIK.js +0 -636
  101. package/dist/test-command-WPYLJYIK.js.map +0 -1
  102. package/dist/validator-J4YSBB66.js +0 -33
  103. package/dist/validator-J4YSBB66.js.map +0 -1
  104. /package/dist/{runner-LBQUCG3K.js.map → agent/index.js.map} +0 -0
  105. /package/dist/{json-FK2NSRGC.js.map → json-JMRPUVY2.js.map} +0 -0
@@ -0,0 +1,301 @@
1
+ # Writing spana Tests
2
+
3
+ ## When to use
4
+
5
+ Use this skill when writing, debugging, or iterating on spana E2E test flows. spana is a TypeScript-native E2E testing framework for React Native + Web that uses `flow()` files instead of traditional test suites.
6
+
7
+ ## Quick reference
8
+
9
+ ### Discover elements on screen
10
+
11
+ ```bash
12
+ spana selectors --platform web # JSON array of interactable elements with suggested selectors
13
+ spana selectors --platform android # same for Android
14
+ spana selectors --platform ios # same for iOS
15
+ spana hierarchy --platform web # full accessibility tree (includes non-interactable elements)
16
+ ```
17
+
18
+ Filter with `jq`:
19
+
20
+ ```bash
21
+ spana selectors --platform web | jq '.[] | select(.testID != null)'
22
+ spana selectors --platform ios | jq '[.[].suggestedSelector]'
23
+ ```
24
+
25
+ ### Write a flow
26
+
27
+ ```ts
28
+ import { flow } from "spana-test";
29
+
30
+ // Simple form
31
+ export default flow("descriptive name", async ({ app, expect, platform }) => {
32
+ // test body
33
+ });
34
+
35
+ // With config
36
+ export default flow(
37
+ "descriptive name",
38
+ { tags: ["smoke"], platforms: ["web", "android"], timeout: 30000 },
39
+ async ({ app, expect, platform }) => {
40
+ // test body
41
+ },
42
+ );
43
+ ```
44
+
45
+ **File naming:** `<name>.flow.ts` in the configured `flowDir` (default `./flows`).
46
+
47
+ **FlowConfig options:**
48
+
49
+ | Option | Type | Default | Description |
50
+ | ------------ | ----------------------------- | ------- | ----------------------------------- |
51
+ | `tags` | `string[]` | -- | Filter with `--tag` |
52
+ | `platforms` | `("web"\|"android"\|"ios")[]` | all | Restrict to specific platforms |
53
+ | `timeout` | `number` | config | Timeout in ms |
54
+ | `autoLaunch` | `boolean` | `true` | Launch app before flow starts |
55
+ | `artifacts` | `ArtifactConfig` | -- | Per-flow artifact capture overrides |
56
+ | `when` | `{ platform?, env? }` | -- | Conditional execution |
57
+
58
+ ### app methods (FlowContext.app)
59
+
60
+ | Method | Description |
61
+ | -------------------------------- | --------------------------------- |
62
+ | `app.tap(selector, opts?)` | Tap element (auto-waits) |
63
+ | `app.tapXY(x, y)` | Tap absolute coordinates |
64
+ | `app.doubleTap(selector, opts?)` | Double-tap element |
65
+ | `app.longPress(selector, opts?)` | Long press (default 1s) |
66
+ | `app.inputText(text)` | Type text into focused element |
67
+ | `app.pressKey(key)` | Press a keyboard key |
68
+ | `app.hideKeyboard()` | Dismiss keyboard |
69
+ | `app.swipe(direction, opts?)` | Swipe: "up"/"down"/"left"/"right" |
70
+ | `app.scroll(direction)` | Scroll (slower swipe) |
71
+ | `app.launch(opts?)` | Launch/relaunch app |
72
+ | `app.stop()` / `app.kill()` | Stop or force-kill app |
73
+ | `app.clearState()` | Clear app data |
74
+ | `app.openLink(url)` | Open deep link or URL |
75
+ | `app.back()` | Navigate back |
76
+ | `app.takeScreenshot(name?)` | Capture screenshot |
77
+ | `app.evaluate(fn, ...args)` | Run JS in web context |
78
+
79
+ `opts` on tap/doubleTap/longPress accepts `{ timeout?: number }` to override wait timeout.
80
+
81
+ ### expect methods (FlowContext.expect)
82
+
83
+ ```ts
84
+ await expect({ testID: "header" }).toBeVisible();
85
+ await expect({ testID: "header" }).toBeVisible({ timeout: 10_000 });
86
+ await expect({ testID: "spinner" }).toBeHidden();
87
+ await expect({ testID: "title" }).toHaveText("Welcome");
88
+ ```
89
+
90
+ | Method | Description |
91
+ | ----------------------------- | ------------------------------------- |
92
+ | `toBeVisible(opts?)` | Assert element is visible on screen |
93
+ | `toBeHidden(opts?)` | Assert element is not visible |
94
+ | `toHaveText(expected, opts?)` | Assert element's text matches exactly |
95
+
96
+ All expect methods auto-wait with polling. Pass `{ timeout: ms }` to override.
97
+
98
+ ### Selector types
99
+
100
+ ```ts
101
+ { testID: "login-btn" } // maps to data-testid (web), resource-id (Android), accessibilityIdentifier (iOS)
102
+ { text: "Sign In" } // visible label text
103
+ { accessibilityLabel: "Close" } // OS accessibility label
104
+ { point: { x: 100, y: 200 } } // absolute coordinate (last resort)
105
+ "Sign In" // shorthand for { text: "Sign In" }
106
+ ```
107
+
108
+ **Selector priority:** `testID` > `accessibilityLabel` > `text` > `point`
109
+
110
+ **Relative selectors** (for ambiguous elements):
111
+
112
+ ```ts
113
+ await app.tap({ selector: { text: "Edit" }, below: { testID: "user-row-1" } });
114
+ await app.tap({ selector: { text: "Delete" }, rightOf: { text: "Item 3" } });
115
+ ```
116
+
117
+ Relative modifiers: `below`, `above`, `leftOf`, `rightOf`, `childOf`.
118
+
119
+ ### Validate without a device
120
+
121
+ ```bash
122
+ spana validate # validates all flows in flowDir
123
+ spana validate flows/ # validate specific directory
124
+ ```
125
+
126
+ Checks: valid exports, no duplicate names, valid platform values, directory exists.
127
+
128
+ ### Run and read results
129
+
130
+ ```bash
131
+ spana test --platform web --reporter json
132
+ spana test flows/login.flow.ts --reporter json
133
+ spana test --tag smoke --platform android --reporter json
134
+ spana test --grep "login" --reporter json
135
+
136
+ # Parse failures
137
+ spana test --reporter json 2>&1 | jq '.results[] | select(.status == "failed")'
138
+ ```
139
+
140
+ ## Agent workflow loop
141
+
142
+ ```
143
+ 1. spana selectors --platform <target> -> discover elements
144
+ 2. Write a .flow.ts file using selectors -> create the test
145
+ 3. spana validate flows/ -> check structure (no device needed)
146
+ 4. spana test <file> --reporter json -> execute on device
147
+ 5. If failed: read error, fix, goto 3
148
+ ```
149
+
150
+ Do not skip step 3. Validation catches export errors, duplicate names, and invalid platforms before spending device time.
151
+
152
+ ## Flow patterns
153
+
154
+ ### Navigation with deep links
155
+
156
+ ```ts
157
+ export default flow(
158
+ "home screen loads",
159
+ { autoLaunch: false },
160
+ async ({ app, expect, platform }) => {
161
+ const url = platform === "web" ? "http://localhost:3000/" : "myapp://home";
162
+ await app.openLink(url);
163
+ await expect({ testID: "home-screen" }).toBeVisible();
164
+ },
165
+ );
166
+ ```
167
+
168
+ ### Form fill
169
+
170
+ ```ts
171
+ await app.tap({ testID: "email-input" });
172
+ await app.inputText("user@example.com");
173
+ await app.tap({ testID: "password-input" });
174
+ await app.inputText("secret123");
175
+ await app.hideKeyboard();
176
+ await app.tap({ testID: "submit-btn" });
177
+ await expect({ testID: "dashboard" }).toBeVisible();
178
+ ```
179
+
180
+ ### Scrolling to find content
181
+
182
+ ```ts
183
+ await app.scroll("down");
184
+ await expect({ testID: "footer-section" }).toBeVisible({ timeout: 10_000 });
185
+ ```
186
+
187
+ ### Platform branching
188
+
189
+ ```ts
190
+ async ({ app, expect, platform }) => {
191
+ await app.tap({ testID: "menu-btn" });
192
+ if (platform === "android") {
193
+ await app.back(); // close drawer via back button
194
+ }
195
+ if (platform === "web") {
196
+ await app.evaluate(() => window.scrollTo(0, 0));
197
+ }
198
+ };
199
+ ```
200
+
201
+ ### Artifact capture per flow
202
+
203
+ ```ts
204
+ export default flow(
205
+ "checkout flow",
206
+ { artifacts: { captureOnSuccess: true, captureSteps: true } },
207
+ async ({ app, expect }) => {
208
+ /* ... */
209
+ },
210
+ );
211
+ ```
212
+
213
+ ## Platform-specific notes
214
+
215
+ ### Web
216
+
217
+ - Uses Playwright (CDP). No companion binary needed.
218
+ - `testID` maps to `data-testid` attribute.
219
+ - `app.evaluate()` runs JS in the browser context.
220
+ - Default `baseUrl`: `http://localhost:3000`.
221
+
222
+ ### Android
223
+
224
+ - Uses UiAutomator2 HTTP server (APK auto-installed on device).
225
+ - `testID` maps to `resource-id`.
226
+ - `app.back()` triggers the system back button.
227
+ - Emulators and physical devices supported.
228
+
229
+ ### iOS
230
+
231
+ - Uses WebDriverAgent (XCTest bundle).
232
+ - `testID` maps to `accessibilityIdentifier`.
233
+ - Simulators: works out of the box.
234
+ - Physical devices: requires code signing config in `spana.config.ts`.
235
+ - `app.back()` may not work the same as Android; prefer tap on back button element.
236
+
237
+ ## Error handling
238
+
239
+ | Error | Cause | Fix |
240
+ | ----------------------------- | -------------------------------------------- | ----------------------------------------------------------------------- |
241
+ | `Element not found: {...}` | Selector does not match any visible element | Run `spana selectors` to verify element exists and get correct selector |
242
+ | `Timeout waiting for element` | Element didn't appear within wait timeout | Increase `timeout` in opts, or check if prior navigation succeeded |
243
+ | `Duplicate flow name` | Two flow files export the same `name` string | Rename one of the flows |
244
+ | `Invalid platform` | Platform string is not web/android/ios | Fix the `platforms` array in FlowConfig |
245
+ | `No Android device connected` | No emulator/device available | Start emulator or connect device, verify with `spana devices` |
246
+ | `No iOS simulator available` | No booted simulator found | Boot a simulator: `xcrun simctl boot <udid>` |
247
+
248
+ When a flow fails at runtime, the JSON reporter includes the error message and the step that failed. Read the `results[].error` field to diagnose.
249
+
250
+ ## Config reference
251
+
252
+ `spana.config.ts` at project root:
253
+
254
+ ```ts
255
+ import { defineConfig } from "spana-test";
256
+
257
+ export default defineConfig({
258
+ apps: {
259
+ web: { url: "http://localhost:3000" },
260
+ android: { packageName: "com.example.app" },
261
+ ios: { bundleId: "com.example.app", appPath: "./MyApp.app" },
262
+ },
263
+ platforms: ["web", "android", "ios"],
264
+ flowDir: "./flows",
265
+ reporters: ["console", "json", "html"],
266
+ defaults: {
267
+ waitTimeout: 5000, // ms to wait for element visibility
268
+ pollInterval: 200, // ms between hierarchy polls
269
+ settleTimeout: 300, // ms of stability before match
270
+ retries: 2, // retries on action failure
271
+ },
272
+ artifacts: {
273
+ outputDir: ".spana/artifacts",
274
+ captureOnFailure: true,
275
+ captureOnSuccess: false,
276
+ screenshot: true,
277
+ uiHierarchy: true,
278
+ },
279
+ hooks: {
280
+ beforeAll: async ({ app }) => {
281
+ /* global setup */
282
+ },
283
+ beforeEach: async ({ app }) => {
284
+ /* per-flow setup, e.g. clear state */
285
+ },
286
+ afterEach: async ({ app, result }) => {
287
+ /* per-flow teardown */
288
+ },
289
+ afterAll: async ({ app, summary }) => {
290
+ /* global cleanup */
291
+ },
292
+ },
293
+ });
294
+ ```
295
+
296
+ Key config options for agents:
297
+
298
+ - `flowDir`: where to put flow files (default `./flows`)
299
+ - `defaults.waitTimeout`: how long auto-wait polls before failing
300
+ - `artifacts.captureOnFailure`: auto-capture screenshots on failure (useful for debugging)
301
+ - `reporters`: use `["json"]` for machine-readable output
package/README.md CHANGED
@@ -21,13 +21,15 @@ TypeScript-native E2E testing for React Native + Web
21
21
  ## Quick Start
22
22
 
23
23
  ```bash
24
+ npm install spana-test
25
+ # or
24
26
  bun add spana-test
25
27
  ```
26
28
 
27
29
  Create `spana.config.ts`:
28
30
 
29
31
  ```ts
30
- import { defineConfig } from "spana";
32
+ import { defineConfig } from "spana-test";
31
33
 
32
34
  export default defineConfig({
33
35
  apps: {
@@ -42,7 +44,7 @@ export default defineConfig({
42
44
  Create `flows/login.ts`:
43
45
 
44
46
  ```ts
45
- import { flow } from "spana";
47
+ import { flow } from "spana-test";
46
48
 
47
49
  export default flow("user can log in", async ({ app, expect }) => {
48
50
  await app.tap({ testID: "email-input" });
@@ -67,7 +69,7 @@ spana test
67
69
  ### Basic API
68
70
 
69
71
  ```ts
70
- import { flow } from "spana";
72
+ import { flow } from "spana-test";
71
73
 
72
74
  export default flow("flow name", async ({ app, expect, platform }) => {
73
75
  // tap, type, scroll
@@ -144,7 +146,7 @@ spana selectors --platform ios
144
146
  ## Configuration
145
147
 
146
148
  ```ts
147
- import { defineConfig } from "spana";
149
+ import { defineConfig } from "spana-test";
148
150
 
149
151
  export default defineConfig({
150
152
  apps: {
@@ -152,6 +154,13 @@ export default defineConfig({
152
154
  android: { packageName: "com.example.app" },
153
155
  ios: { bundleId: "com.example.app" },
154
156
  },
157
+ execution: {
158
+ web: {
159
+ browser: "chromium",
160
+ headless: true,
161
+ storageState: "./auth/web-user.json",
162
+ },
163
+ },
155
164
  platforms: ["web", "android", "ios"],
156
165
  flowDir: "./flows",
157
166
  reporters: ["console", "json", "html"],
@@ -185,6 +194,26 @@ export default defineConfig({
185
194
  });
186
195
  ```
187
196
 
197
+ `execution.web` controls the local Playwright runtime for web flows. Use it to switch browser engines, run headed for debugging, or preload a saved storage state file.
198
+
199
+ ### Browser runtime helpers (web)
200
+
201
+ ```ts
202
+ export default flow("web dashboard", async ({ app, platform }) => {
203
+ if (platform !== "web") return;
204
+
205
+ await app.loadAuthState("./auth/web-user.json");
206
+ await app.mockNetwork("**/api/dashboard", {
207
+ json: { widgets: ["revenue", "alerts"] },
208
+ });
209
+ await app.blockNetwork("**/analytics/**");
210
+ await app.setNetworkConditions({ offline: false, latencyMs: 120 });
211
+ await app.saveCookies("./tmp/cookies.json");
212
+ });
213
+ ```
214
+
215
+ `mockNetwork`, `blockNetwork`, `clearNetworkMocks`, `setNetworkConditions`, `saveCookies`, `loadCookies`, `saveAuthState`, and `loadAuthState` are web-only helpers backed by Playwright. Latency and throughput throttling require the Chromium browser runtime.
216
+
188
217
  ---
189
218
 
190
219
  ## Selectors
@@ -0,0 +1,81 @@
1
+ import { P as Platform, b as BrowserName, g as RawDriverService, S as Selector, E as ExtendedSelector, L as LaunchOptions, d as BrowserRouteMatcher, B as BrowserMockResponse, c as BrowserNetworkConditions } from '../config-Dg9O0rcQ.js';
2
+ import { E as Element } from '../element-CGteXiXB.js';
3
+ import 'effect';
4
+
5
+ type Direction = "up" | "down" | "left" | "right";
6
+ interface ConnectOptions {
7
+ platform: Platform;
8
+ device?: string;
9
+ baseUrl?: string;
10
+ packageName?: string;
11
+ bundleId?: string;
12
+ headless?: boolean;
13
+ browser?: BrowserName;
14
+ storageState?: string;
15
+ }
16
+ interface SuggestedSelector {
17
+ suggestedSelector: Selector;
18
+ elementType?: string;
19
+ text?: string;
20
+ accessibilityLabel?: string;
21
+ bounds: {
22
+ x: number;
23
+ y: number;
24
+ width: number;
25
+ height: number;
26
+ };
27
+ id?: string;
28
+ }
29
+ declare class Session {
30
+ private driver;
31
+ private appId;
32
+ readonly platform: Platform;
33
+ private parse;
34
+ private cleanups;
35
+ constructor(driver: RawDriverService, platform: Platform, parse: (raw: string) => Element, appId?: string, cleanups?: (() => void)[]);
36
+ hierarchy(): Promise<Element>;
37
+ selectors(): Promise<SuggestedSelector[]>;
38
+ tap(selector: ExtendedSelector): Promise<void>;
39
+ tapXY(x: number, y: number): Promise<void>;
40
+ doubleTap(selector: ExtendedSelector): Promise<void>;
41
+ longPress(selector: ExtendedSelector, opts?: {
42
+ duration?: number;
43
+ }): Promise<void>;
44
+ longPressXY(x: number, y: number, opts?: {
45
+ duration?: number;
46
+ }): Promise<void>;
47
+ swipe(direction: Direction, opts?: {
48
+ duration?: number;
49
+ }): Promise<void>;
50
+ scroll(direction: Direction): Promise<void>;
51
+ inputText(text: string): Promise<void>;
52
+ pressKey(key: string): Promise<void>;
53
+ hideKeyboard(): Promise<void>;
54
+ launch(opts?: LaunchOptions): Promise<void>;
55
+ stop(): Promise<void>;
56
+ kill(): Promise<void>;
57
+ clearState(): Promise<void>;
58
+ openLink(url: string): Promise<void>;
59
+ back(): Promise<void>;
60
+ screenshot(): Promise<Uint8Array>;
61
+ evaluate<T = unknown>(fn: ((...args: any[]) => T) | string, ...args: any[]): Promise<T>;
62
+ mockNetwork(matcher: BrowserRouteMatcher, response: BrowserMockResponse): Promise<void>;
63
+ blockNetwork(matcher: BrowserRouteMatcher): Promise<void>;
64
+ clearNetworkMocks(): Promise<void>;
65
+ setNetworkConditions(conditions: BrowserNetworkConditions): Promise<void>;
66
+ saveCookies(path: string): Promise<void>;
67
+ loadCookies(path: string): Promise<void>;
68
+ saveAuthState(path: string): Promise<void>;
69
+ loadAuthState(path: string): Promise<void>;
70
+ disconnect(): Promise<void>;
71
+ }
72
+ /** Connect to a device and create a persistent session */
73
+ declare function connect(opts: ConnectOptions): Promise<Session>;
74
+
75
+ interface ValidationError {
76
+ file: string;
77
+ error: string;
78
+ }
79
+ declare function validateFlows(paths: string[]): Promise<ValidationError[]>;
80
+
81
+ export { type ConnectOptions, type Direction, Session, type SuggestedSelector, type ValidationError, connect, validateFlows };
@@ -0,0 +1,21 @@
1
+ import {
2
+ Session,
3
+ connect
4
+ } from "../chunk-VDWWIVM6.js";
5
+ import "../chunk-CKJQX73M.js";
6
+ import {
7
+ validateFlows
8
+ } from "../chunk-BZRLA4Z3.js";
9
+ import "../chunk-5XO6S7AI.js";
10
+ import "../chunk-U564GCO2.js";
11
+ import "../chunk-RK4Z6C7M.js";
12
+ import "../chunk-WIJYK22K.js";
13
+ import "../chunk-GZK22EIE.js";
14
+ import "../chunk-V62HFH6E.js";
15
+ import "../chunk-DGUM43GV.js";
16
+ export {
17
+ Session,
18
+ connect,
19
+ validateFlows
20
+ };
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,124 @@
1
+ import "./chunk-DGUM43GV.js";
2
+
3
+ // src/report/allure.ts
4
+ import { randomUUID, createHash } from "crypto";
5
+ import { writeFileSync, mkdirSync, copyFileSync, existsSync } from "fs";
6
+ import { join } from "path";
7
+ function historyId(name, platform) {
8
+ return createHash("md5").update(`${name}:${platform}`).digest("hex");
9
+ }
10
+ function allureStatus(status) {
11
+ if (status === "passed") return "passed";
12
+ if (status === "failed") return "failed";
13
+ if (status === "skipped") return "skipped";
14
+ return "broken";
15
+ }
16
+ function mapSteps(steps, startTime) {
17
+ let time = startTime;
18
+ return steps.map((step) => {
19
+ const stepStart = time;
20
+ const stepStop = time + step.durationMs;
21
+ time = stepStop;
22
+ return {
23
+ name: step.selector ? `${step.command} ${JSON.stringify(step.selector)}` : step.command,
24
+ status: allureStatus(step.status),
25
+ start: stepStart,
26
+ stop: stepStop,
27
+ steps: [],
28
+ ...step.error ? { statusDetails: { message: step.error } } : {}
29
+ };
30
+ });
31
+ }
32
+ function copyAttachments(result, outputDir) {
33
+ const allureAttachments = [];
34
+ for (const att of result.attachments ?? []) {
35
+ if (att.path && existsSync(att.path)) {
36
+ const ext = att.contentType === "image/png" ? ".png" : ".json";
37
+ const filename = `${randomUUID()}-attachment${ext}`;
38
+ copyFileSync(att.path, join(outputDir, filename));
39
+ allureAttachments.push({
40
+ name: att.name,
41
+ source: filename,
42
+ type: att.contentType
43
+ });
44
+ }
45
+ }
46
+ for (const step of result.steps ?? []) {
47
+ for (const att of step.attachments ?? []) {
48
+ if (att.path && existsSync(att.path)) {
49
+ const ext = att.contentType === "image/png" ? ".png" : ".json";
50
+ const filename = `${randomUUID()}-attachment${ext}`;
51
+ copyFileSync(att.path, join(outputDir, filename));
52
+ allureAttachments.push({
53
+ name: att.name,
54
+ source: filename,
55
+ type: att.contentType
56
+ });
57
+ }
58
+ }
59
+ }
60
+ return allureAttachments;
61
+ }
62
+ function writeResult(result, outputDir) {
63
+ const uuid = randomUUID();
64
+ const now = Date.now();
65
+ const startTime = now - result.durationMs;
66
+ const labels = [
67
+ { name: "suite", value: result.platform },
68
+ { name: "framework", value: "spana" }
69
+ ];
70
+ if (result.flaky) {
71
+ labels.push({ name: "tag", value: "flaky" });
72
+ }
73
+ const allureResult = {
74
+ uuid,
75
+ historyId: historyId(result.name, result.platform),
76
+ name: result.name,
77
+ fullName: `[${result.platform}] ${result.name}`,
78
+ status: result.flaky ? "passed" : allureStatus(result.status),
79
+ stage: "finished",
80
+ start: startTime,
81
+ stop: now,
82
+ labels,
83
+ steps: result.steps ? mapSteps(result.steps, startTime) : [],
84
+ attachments: copyAttachments(result, outputDir)
85
+ };
86
+ if (result.error) {
87
+ allureResult.statusDetails = {
88
+ message: result.error.message,
89
+ trace: result.error.stack
90
+ };
91
+ } else if (result.flaky) {
92
+ allureResult.statusDetails = {
93
+ message: `Flaky: passed on attempt ${result.attempts}`
94
+ };
95
+ }
96
+ writeFileSync(join(outputDir, `${uuid}-result.json`), JSON.stringify(allureResult, null, 2));
97
+ }
98
+ function createAllureReporter(outputDir = "allure-results") {
99
+ mkdirSync(outputDir, { recursive: true });
100
+ return {
101
+ onFlowPass(result) {
102
+ writeResult(result, outputDir);
103
+ },
104
+ onFlowFail(result) {
105
+ writeResult(result, outputDir);
106
+ },
107
+ onRunComplete(summary) {
108
+ const envContent = [
109
+ `Platform=${summary.platforms.join(", ")}`,
110
+ `Framework=spana`,
111
+ `Total=${summary.total}`,
112
+ `Passed=${summary.passed}`,
113
+ `Failed=${summary.failed}`
114
+ ].join("\n");
115
+ writeFileSync(join(outputDir, "environment.properties"), envContent);
116
+ console.log(`Allure results written to ${outputDir}/`);
117
+ console.log(`Run: npx allure generate ${outputDir} --clean -o allure-report`);
118
+ }
119
+ };
120
+ }
121
+ export {
122
+ createAllureReporter
123
+ };
124
+ //# sourceMappingURL=allure-PTTVORQ6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/report/allure.ts"],"sourcesContent":["import { randomUUID, createHash } from \"node:crypto\";\nimport { writeFileSync, mkdirSync, copyFileSync, existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { Reporter, FlowResult, StepResult } from \"./types.js\";\n\nfunction historyId(name: string, platform: string): string {\n return createHash(\"md5\").update(`${name}:${platform}`).digest(\"hex\");\n}\n\nfunction allureStatus(status: string): string {\n if (status === \"passed\") return \"passed\";\n if (status === \"failed\") return \"failed\";\n if (status === \"skipped\") return \"skipped\";\n return \"broken\";\n}\n\nfunction mapSteps(steps: StepResult[], startTime: number): unknown[] {\n let time = startTime;\n return steps.map((step) => {\n const stepStart = time;\n const stepStop = time + step.durationMs;\n time = stepStop;\n return {\n name: step.selector ? `${step.command} ${JSON.stringify(step.selector)}` : step.command,\n status: allureStatus(step.status),\n start: stepStart,\n stop: stepStop,\n steps: [],\n ...(step.error ? { statusDetails: { message: step.error } } : {}),\n };\n });\n}\n\nfunction copyAttachments(result: FlowResult, outputDir: string): unknown[] {\n const allureAttachments: unknown[] = [];\n\n // Flow-level attachments\n for (const att of result.attachments ?? []) {\n if (att.path && existsSync(att.path)) {\n const ext = att.contentType === \"image/png\" ? \".png\" : \".json\";\n const filename = `${randomUUID()}-attachment${ext}`;\n copyFileSync(att.path, join(outputDir, filename));\n allureAttachments.push({\n name: att.name,\n source: filename,\n type: att.contentType,\n });\n }\n }\n\n // Step-level attachments\n for (const step of result.steps ?? []) {\n for (const att of step.attachments ?? []) {\n if (att.path && existsSync(att.path)) {\n const ext = att.contentType === \"image/png\" ? \".png\" : \".json\";\n const filename = `${randomUUID()}-attachment${ext}`;\n copyFileSync(att.path, join(outputDir, filename));\n allureAttachments.push({\n name: att.name,\n source: filename,\n type: att.contentType,\n });\n }\n }\n }\n\n return allureAttachments;\n}\n\nfunction writeResult(result: FlowResult, outputDir: string): void {\n const uuid = randomUUID();\n const now = Date.now();\n const startTime = now - result.durationMs;\n\n const labels: { name: string; value: string }[] = [\n { name: \"suite\", value: result.platform },\n { name: \"framework\", value: \"spana\" },\n ];\n\n if (result.flaky) {\n labels.push({ name: \"tag\", value: \"flaky\" });\n }\n\n const allureResult: Record<string, unknown> = {\n uuid,\n historyId: historyId(result.name, result.platform),\n name: result.name,\n fullName: `[${result.platform}] ${result.name}`,\n status: result.flaky ? \"passed\" : allureStatus(result.status),\n stage: \"finished\",\n start: startTime,\n stop: now,\n labels,\n steps: result.steps ? mapSteps(result.steps, startTime) : [],\n attachments: copyAttachments(result, outputDir),\n };\n\n if (result.error) {\n allureResult.statusDetails = {\n message: result.error.message,\n trace: result.error.stack,\n };\n } else if (result.flaky) {\n allureResult.statusDetails = {\n message: `Flaky: passed on attempt ${result.attempts}`,\n };\n }\n\n writeFileSync(join(outputDir, `${uuid}-result.json`), JSON.stringify(allureResult, null, 2));\n}\n\nexport function createAllureReporter(outputDir: string = \"allure-results\"): Reporter {\n mkdirSync(outputDir, { recursive: true });\n\n return {\n onFlowPass(result: FlowResult) {\n writeResult(result, outputDir);\n },\n\n onFlowFail(result: FlowResult) {\n writeResult(result, outputDir);\n },\n\n onRunComplete(summary) {\n const envContent = [\n `Platform=${summary.platforms.join(\", \")}`,\n `Framework=spana`,\n `Total=${summary.total}`,\n `Passed=${summary.passed}`,\n `Failed=${summary.failed}`,\n ].join(\"\\n\");\n writeFileSync(join(outputDir, \"environment.properties\"), envContent);\n\n console.log(`Allure results written to ${outputDir}/`);\n console.log(`Run: npx allure generate ${outputDir} --clean -o allure-report`);\n },\n };\n}\n"],"mappings":";;;AAAA,SAAS,YAAY,kBAAkB;AACvC,SAAS,eAAe,WAAW,cAAc,kBAAkB;AACnE,SAAS,YAA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vB,iBAAa,gBAAgB;AAAA,MAC3B,SAAS,4BAA4B,OAAO,QAAQ;AAAA,IACtD;AAAA,EACF;AAEA,gBAAc,KAAK,WAAW,GAAG,IAAI,cAAc,GAAG,KAAK,UAAU,cAAc,MAAM,CAAC,CAAC;AAC7F;AAEO,SAAS,qBAAqB,YAAoB,kBAA4B;AACnF,YAAU,WAAW,EAAE,WAAW,KAAK,CAAC;AAExC,SAAO;AAAA,IACL,WAAW,QAAoB;AAC7B,kBAAY,QAAQ,SAAS;AAAA,IAC/B;AAAA,IAEA,WAAW,QAAoB;AAC7B,kBAAY,QAAQ,SAAS;AAAA,IAC/B;AAAA,IAEA,cAAc,SAAS;AACrB,YAAM,aAAa;AAAA,QACjB,YAAY,QAAQ,UAAU,KAAK,IAAI,CAAC;AAAA,QACxC;AAAA,QACA,SAAS,QAAQ,KAAK;AAAA,QACtB,UAAU,QAAQ,MAAM;AAAA,QACxB,UAAU,QAAQ,MAAM;AAAA,MAC1B,EAAE,KAAK,IAAI;AACX,oBAAc,KAAK,WAAW,wBAAwB,GAAG,UAAU;AAEnE,cAAQ,IAAI,6BAA6B,SAAS,GAAG;AACrD,cAAQ,IAAI,4BAA4B,SAAS,2BAA2B;AAAA,IAC9E;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,34 @@
1
+ import {
2
+ adbClearApp,
3
+ adbForceStop,
4
+ adbForward,
5
+ adbInstall,
6
+ adbLaunchApp,
7
+ adbOpenLink,
8
+ adbShell,
9
+ ensureAndroidDevice,
10
+ findADB,
11
+ findEmulator,
12
+ firstAndroidDevice,
13
+ listAVDs,
14
+ listAndroidDevices,
15
+ startEmulator
16
+ } from "./chunk-GZK22EIE.js";
17
+ import "./chunk-DGUM43GV.js";
18
+ export {
19
+ adbClearApp,
20
+ adbForceStop,
21
+ adbForward,
22
+ adbInstall,
23
+ adbLaunchApp,
24
+ adbOpenLink,
25
+ adbShell,
26
+ ensureAndroidDevice,
27
+ findADB,
28
+ findEmulator,
29
+ firstAndroidDevice,
30
+ listAVDs,
31
+ listAndroidDevices,
32
+ startEmulator
33
+ };
34
+ //# sourceMappingURL=android-PAPJJWVN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}