spana-test 0.0.1 → 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 +276 -0
  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-PF7V37UD.js → chunk-CKJQX73M.js} +897 -845
  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-HKDZMXD7.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-4EZKZ5RO.js → chunk-WIJYK22K.js} +12 -5
  38. package/dist/{discover-4EZKZ5RO.js.map → chunk-WIJYK22K.js.map} +1 -1
  39. package/dist/cli.js +135 -17
  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-OGRQ5NIX.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-3TZD6FI5.js → json-JMRPUVY2.js} +2 -2
  67. package/dist/{junit-ES66OYVX.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 +43 -5
  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-HKDZMXD7.js.map +0 -1
  90. package/dist/chunk-PF7V37UD.js.map +0 -1
  91. package/dist/chunk-Y7MNYLGH.js +0 -64
  92. package/dist/chunk-Y7MNYLGH.js.map +0 -1
  93. package/dist/console-ZH3SUKUO.js +0 -71
  94. package/dist/console-ZH3SUKUO.js.map +0 -1
  95. package/dist/html-OGRQ5NIX.js.map +0 -1
  96. package/dist/junit-ES66OYVX.js.map +0 -1
  97. package/dist/runner-NGLCXD2E.js +0 -12
  98. package/dist/session-NWNZWWNI.js +0 -122
  99. package/dist/session-NWNZWWNI.js.map +0 -1
  100. package/dist/test-command-F3AEHF2E.js +0 -636
  101. package/dist/test-command-F3AEHF2E.js.map +0 -1
  102. package/dist/validator-LHN66ZH7.js +0 -33
  103. package/dist/validator-LHN66ZH7.js.map +0 -1
  104. /package/dist/{runner-NGLCXD2E.js.map → agent/index.js.map} +0 -0
  105. /package/dist/{json-3TZD6FI5.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 ADDED
@@ -0,0 +1,276 @@
1
+ # spana
2
+
3
+ TypeScript-native E2E testing for React Native + Web
4
+
5
+ [Documentation](https://wezter96.github.io/spana/) | [GitHub](https://github.com/wezter96/spana) | [npm](https://www.npmjs.com/package/spana-test) | [E2E Test Report](https://htmlpreview.github.io/?https://github.com/wezter96/spana/blob/main/docs/e2e-report.html)
6
+
7
+ ---
8
+
9
+ ## Features
10
+
11
+ - Pure TypeScript — no YAML, no JVM, no app modification required
12
+ - Cross-platform — Web, Android, iOS from a single test file
13
+ - Web via Playwright (CDP), Android via UiAutomator2, iOS via WebDriverAgent
14
+ - Agent-first design — JSON reporter, hierarchy dump, and selector discovery for AI agents
15
+ - Auto-wait with configurable poll interval, settle timeout, and retries
16
+ - Multiple reporters: console, JSON, JUnit XML, HTML
17
+ - Artifact capture (screenshots + UI hierarchy) on failure
18
+
19
+ ---
20
+
21
+ ## Quick Start
22
+
23
+ ```bash
24
+ npm install spana-test
25
+ # or
26
+ bun add spana-test
27
+ ```
28
+
29
+ Create `spana.config.ts`:
30
+
31
+ ```ts
32
+ import { defineConfig } from "spana-test";
33
+
34
+ export default defineConfig({
35
+ apps: {
36
+ web: { url: "http://localhost:3000" },
37
+ android: { packageName: "com.example.app" },
38
+ ios: { bundleId: "com.example.app" },
39
+ },
40
+ platforms: ["web", "android"],
41
+ });
42
+ ```
43
+
44
+ Create `flows/login.ts`:
45
+
46
+ ```ts
47
+ import { flow } from "spana-test";
48
+
49
+ export default flow("user can log in", async ({ app, expect }) => {
50
+ await app.tap({ testID: "email-input" });
51
+ await app.typeText("user@example.com");
52
+ await app.tap({ testID: "password-input" });
53
+ await app.typeText("secret");
54
+ await app.tap({ testID: "login-button" });
55
+ await expect({ testID: "home-screen" }).toBeVisible();
56
+ });
57
+ ```
58
+
59
+ Run:
60
+
61
+ ```bash
62
+ spana test
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Writing Flows
68
+
69
+ ### Basic API
70
+
71
+ ```ts
72
+ import { flow } from "spana-test";
73
+
74
+ export default flow("flow name", async ({ app, expect, platform }) => {
75
+ // tap, type, scroll
76
+ await app.tap({ text: "Sign In" });
77
+ await app.typeText("hello");
78
+ await app.scroll({ direction: "down" });
79
+
80
+ // assertions
81
+ await expect({ testID: "welcome" }).toBeVisible();
82
+ await expect({ text: "Welcome" }).toBeVisible();
83
+
84
+ // platform branching
85
+ if (platform === "web") {
86
+ await app.tap({ testID: "web-only-button" });
87
+ }
88
+ });
89
+ ```
90
+
91
+ ### With config
92
+
93
+ ```ts
94
+ export default flow(
95
+ "checkout flow",
96
+ { tags: ["smoke", "payments"], platforms: ["android", "ios"], timeout: 60000 },
97
+ async ({ app, expect }) => {
98
+ // ...
99
+ },
100
+ );
101
+ ```
102
+
103
+ ### FlowConfig options
104
+
105
+ | Option | Type | Default | Description |
106
+ | ------------ | ------------ | -------------- | ------------------------------ |
107
+ | `tags` | `string[]` | — | Tag for filtering with `--tag` |
108
+ | `platforms` | `Platform[]` | all | Restrict to specific platforms |
109
+ | `timeout` | `number` | config default | Timeout in ms for this flow |
110
+ | `autoLaunch` | `boolean` | `true` | Launch app before flow starts |
111
+
112
+ ---
113
+
114
+ ## CLI Commands
115
+
116
+ | Command | Description |
117
+ | ----------------------- | ------------------------------------------------- |
118
+ | `spana test [path]` | Run test flows (default: `./flows`) |
119
+ | `spana hierarchy` | Dump full element hierarchy as JSON |
120
+ | `spana selectors` | List actionable elements with suggested selectors |
121
+ | `spana validate [path]` | Validate flow files without a device connection |
122
+ | `spana devices` | List connected devices across all platforms |
123
+ | `spana version` | Show version |
124
+
125
+ ### test options
126
+
127
+ ```bash
128
+ spana test flows/login.ts # run a single file
129
+ spana test --platform android,ios # target platforms (default: web)
130
+ spana test --tag smoke # filter by tag
131
+ spana test --grep "log in" # filter by name pattern
132
+ spana test --reporter json # reporter format
133
+ spana test --reporter html # self-contained HTML report
134
+ spana test --config ./spana.config.ts # explicit config path
135
+ ```
136
+
137
+ ### hierarchy / selectors options
138
+
139
+ ```bash
140
+ spana hierarchy --platform android --pretty
141
+ spana selectors --platform ios
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Configuration
147
+
148
+ ```ts
149
+ import { defineConfig } from "spana-test";
150
+
151
+ export default defineConfig({
152
+ apps: {
153
+ web: { url: "http://localhost:3000" },
154
+ android: { packageName: "com.example.app" },
155
+ ios: { bundleId: "com.example.app" },
156
+ },
157
+ execution: {
158
+ web: {
159
+ browser: "chromium",
160
+ headless: true,
161
+ storageState: "./auth/web-user.json",
162
+ },
163
+ },
164
+ platforms: ["web", "android", "ios"],
165
+ flowDir: "./flows",
166
+ reporters: ["console", "json", "html"],
167
+ defaults: {
168
+ waitTimeout: 5000, // ms to wait for element
169
+ pollInterval: 200, // ms between polls
170
+ settleTimeout: 300, // ms of stability before match
171
+ retries: 2, // retries on action failure
172
+ },
173
+ artifacts: {
174
+ outputDir: ".spana/artifacts",
175
+ captureOnFailure: true, // screenshot + hierarchy on failure
176
+ captureOnSuccess: false,
177
+ screenshot: true,
178
+ uiHierarchy: true,
179
+ },
180
+ hooks: {
181
+ beforeAll: async ({ app }) => {
182
+ /* setup */
183
+ },
184
+ beforeEach: async ({ app }) => {
185
+ /* reset state */
186
+ },
187
+ afterEach: async ({ app, result }) => {
188
+ /* teardown */
189
+ },
190
+ afterAll: async ({ app, summary }) => {
191
+ /* cleanup */
192
+ },
193
+ },
194
+ });
195
+ ```
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
+
217
+ ---
218
+
219
+ ## Selectors
220
+
221
+ | Selector | Example | Notes |
222
+ | -------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------- |
223
+ | `testID` | `{ testID: "login-btn" }` | Preferred — maps to `accessibilityIdentifier` (iOS), `resource-id` (Android), `data-testid` (web) |
224
+ | `text` | `{ text: "Sign In" }` | Visible label text, partial match supported |
225
+ | `accessibilityLabel` | `{ accessibilityLabel: "Close" }` | OS accessibility label |
226
+ | `point` | `{ point: { x: 100, y: 200 } }` | Absolute coordinate tap, use as last resort |
227
+
228
+ Selectors can be combined. When multiple fields are set, all must match.
229
+
230
+ ---
231
+
232
+ ## Agent Integration
233
+
234
+ `spana` is designed for AI agent workflows:
235
+
236
+ - `spana selectors --platform android` returns JSON with element details and suggested selectors — feed this to an agent to identify what to interact with
237
+ - `spana hierarchy --platform web --pretty` dumps the full accessibility tree as structured JSON
238
+ - `spana validate` exits non-zero on invalid flows — use in CI preflight
239
+ - `--reporter json` emits structured JSON events to stdout — pipe to an agent for result analysis
240
+
241
+ Example agent loop:
242
+
243
+ ```bash
244
+ # 1. discover what's on screen
245
+ spana selectors --platform web | jq '.[] | select(.testID != null)'
246
+
247
+ # 2. run a specific flow with JSON output
248
+ spana test flows/login.ts --reporter json 2>&1 | jq '.results'
249
+ ```
250
+
251
+ ---
252
+
253
+ ## Architecture
254
+
255
+ spana uses a layered architecture: CLI -> TestRunner -> PlatformOrchestrator -> SmartLayer -> RawDriver.
256
+
257
+ Raw drivers are thin HTTP clients. All selector matching, auto-wait, retry, and element resolution lives in the TypeScript SmartLayer — no logic in companion binaries.
258
+
259
+ See [ARCHITECTURE.md](./ARCHITECTURE.md) for details.
260
+
261
+ ---
262
+
263
+ ## Platforms
264
+
265
+ | Platform | Driver | Companion binary |
266
+ | ------------- | -------------------------- | ----------------------------------------------------------------- |
267
+ | Web / RN Web | Playwright (CDP) | None — Playwright is a dev dependency |
268
+ | Android | UiAutomator2 HTTP client | Appium UiAutomator2 server APK (bundled, ~2-3 MB) |
269
+ | iOS Simulator | WebDriverAgent HTTP client | WDA XCTest bundle (bundled unsigned, ~5 MB) |
270
+ | iOS Device | Same WDA bundle | Re-signed with user certificate via `codesign`; requires `iproxy` |
271
+
272
+ ---
273
+
274
+ ## License
275
+
276
+ Apache-2.0
@@ -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