spana-test 0.0.2 → 0.2.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 (124) hide show
  1. package/.agents/skills/spana-testing/SKILL.md +304 -0
  2. package/README.md +308 -88
  3. package/dist/agent/index.d.ts +110 -0
  4. package/dist/agent/index.js +25 -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-3YR4GUGE.js +249 -0
  12. package/dist/chunk-3YR4GUGE.js.map +1 -0
  13. package/dist/{discover-XIRJTZ7Z.js → chunk-AEKDFFPJ.js} +12 -5
  14. package/dist/{discover-XIRJTZ7Z.js.map → chunk-AEKDFFPJ.js.map} +1 -1
  15. package/dist/chunk-BF37W5EG.js +125 -0
  16. package/dist/chunk-BF37W5EG.js.map +1 -0
  17. package/dist/chunk-DGUM43GV.js +11 -0
  18. package/dist/chunk-DGUM43GV.js.map +1 -0
  19. package/dist/chunk-EXLUY7KT.js +21 -0
  20. package/dist/chunk-EXLUY7KT.js.map +1 -0
  21. package/dist/chunk-FNDOEMOL.js +62 -0
  22. package/dist/chunk-FNDOEMOL.js.map +1 -0
  23. package/dist/{chunk-CYEDLQJ4.js → chunk-GZK22EIE.js} +76 -102
  24. package/dist/chunk-GZK22EIE.js.map +1 -0
  25. package/dist/chunk-HWFDXIXR.js +183 -0
  26. package/dist/chunk-HWFDXIXR.js.map +1 -0
  27. package/dist/chunk-IJIASIX5.js +314 -0
  28. package/dist/chunk-IJIASIX5.js.map +1 -0
  29. package/dist/chunk-KJPHH2TW.js +168 -0
  30. package/dist/chunk-KJPHH2TW.js.map +1 -0
  31. package/dist/chunk-L7MFJF46.js +137 -0
  32. package/dist/chunk-L7MFJF46.js.map +1 -0
  33. package/dist/chunk-MRH7SK52.js +134 -0
  34. package/dist/chunk-MRH7SK52.js.map +1 -0
  35. package/dist/chunk-P7JQRLP4.js +114 -0
  36. package/dist/chunk-P7JQRLP4.js.map +1 -0
  37. package/dist/chunk-S2XNAKSO.js +1087 -0
  38. package/dist/chunk-S2XNAKSO.js.map +1 -0
  39. package/dist/chunk-S4R4OR7T.js +358 -0
  40. package/dist/chunk-S4R4OR7T.js.map +1 -0
  41. package/dist/chunk-SFBRFB2N.js +277 -0
  42. package/dist/chunk-SFBRFB2N.js.map +1 -0
  43. package/dist/chunk-VNYF5BHX.js +494 -0
  44. package/dist/chunk-VNYF5BHX.js.map +1 -0
  45. package/dist/chunk-WBU34APM.js +38 -0
  46. package/dist/chunk-WBU34APM.js.map +1 -0
  47. package/dist/chunk-WQ4GXUUE.js +2402 -0
  48. package/dist/chunk-WQ4GXUUE.js.map +1 -0
  49. package/dist/chunk-YBZCOQXJ.js +311 -0
  50. package/dist/chunk-YBZCOQXJ.js.map +1 -0
  51. package/dist/cli.js +428 -34
  52. package/dist/cli.js.map +1 -1
  53. package/dist/compiler-74VGKZO6.js +312 -0
  54. package/dist/compiler-74VGKZO6.js.map +1 -0
  55. package/dist/config-loader-BJJ3IJJ7.js +9 -0
  56. package/dist/config-loader-BJJ3IJJ7.js.map +1 -0
  57. package/dist/console-XWKUTP3D.js +164 -0
  58. package/dist/console-XWKUTP3D.js.map +1 -0
  59. package/dist/coordinator-BbUjvvnX.d.ts +383 -0
  60. package/dist/discover-KZKXHZZA.js +14 -0
  61. package/dist/discover-KZKXHZZA.js.map +1 -0
  62. package/dist/doctor-command-T2UX5RV5.js +732 -0
  63. package/dist/doctor-command-T2UX5RV5.js.map +1 -0
  64. package/dist/element-DZ0HyJ3C.d.ts +25 -0
  65. package/dist/flow-BUC9Mf8W.d.ts +128 -0
  66. package/dist/gherkin/steps.d.ts +32 -0
  67. package/dist/gherkin/steps.js +39 -0
  68. package/dist/gherkin/steps.js.map +1 -0
  69. package/dist/{html-GRB34S6X.js → html-GE6Q4DCG.js} +76 -22
  70. package/dist/html-GE6Q4DCG.js.map +1 -0
  71. package/dist/index.d.ts +159 -144
  72. package/dist/index.js +39 -165
  73. package/dist/index.js.map +1 -1
  74. package/dist/init-command-GVMRXIMY.js +121 -0
  75. package/dist/init-command-GVMRXIMY.js.map +1 -0
  76. package/dist/init-flow-command-R76AXF4Z.js +34 -0
  77. package/dist/init-flow-command-R76AXF4Z.js.map +1 -0
  78. package/dist/installer-YZJ4DV3F.js +22 -0
  79. package/dist/installer-YZJ4DV3F.js.map +1 -0
  80. package/dist/ios-ZW6XVNLG.js +50 -0
  81. package/dist/ios-ZW6XVNLG.js.map +1 -0
  82. package/dist/json-KS67BZYU.js +39 -0
  83. package/dist/json-KS67BZYU.js.map +1 -0
  84. package/dist/{junit-NAGZJOGQ.js → junit-HLC62MK6.js} +15 -4
  85. package/dist/junit-HLC62MK6.js.map +1 -0
  86. package/dist/provider-A57C3MU6.js +12 -0
  87. package/dist/provider-A57C3MU6.js.map +1 -0
  88. package/dist/redact-U72BUBBR.js +77 -0
  89. package/dist/redact-U72BUBBR.js.map +1 -0
  90. package/dist/runner-UXNHVVGG.js +20 -0
  91. package/dist/runner-UXNHVVGG.js.map +1 -0
  92. package/dist/server-W7OA3DDN.js +530 -0
  93. package/dist/server-W7OA3DDN.js.map +1 -0
  94. package/dist/session-TMNOKYLG.js +17 -0
  95. package/dist/session-TMNOKYLG.js.map +1 -0
  96. package/dist/studio-command-6VHTHDUK.js +24 -0
  97. package/dist/studio-command-6VHTHDUK.js.map +1 -0
  98. package/dist/test-command-AHMOZLV4.js +2852 -0
  99. package/dist/test-command-AHMOZLV4.js.map +1 -0
  100. package/dist/validator-35624P7S.js +20 -0
  101. package/dist/validator-35624P7S.js.map +1 -0
  102. package/package.json +41 -4
  103. package/studio-dist/assets/index-DC6DIXfl.js +188 -0
  104. package/studio-dist/assets/index-DDKsnBwD.css +1 -0
  105. package/studio-dist/index.html +13 -0
  106. package/dist/chunk-CYEDLQJ4.js.map +0 -1
  107. package/dist/chunk-PVNNKPBW.js +0 -64
  108. package/dist/chunk-PVNNKPBW.js.map +0 -1
  109. package/dist/chunk-VZZH66U5.js +0 -1781
  110. package/dist/chunk-VZZH66U5.js.map +0 -1
  111. package/dist/console-GPV3M3PC.js +0 -71
  112. package/dist/console-GPV3M3PC.js.map +0 -1
  113. package/dist/html-GRB34S6X.js.map +0 -1
  114. package/dist/json-FK2NSRGC.js +0 -20
  115. package/dist/json-FK2NSRGC.js.map +0 -1
  116. package/dist/junit-NAGZJOGQ.js.map +0 -1
  117. package/dist/runner-LBQUCG3K.js +0 -12
  118. package/dist/session-U7VP5J2C.js +0 -122
  119. package/dist/session-U7VP5J2C.js.map +0 -1
  120. package/dist/test-command-WPYLJYIK.js +0 -636
  121. package/dist/test-command-WPYLJYIK.js.map +0 -1
  122. package/dist/validator-J4YSBB66.js +0 -33
  123. package/dist/validator-J4YSBB66.js.map +0 -1
  124. /package/dist/{runner-LBQUCG3K.js.map → agent/index.js.map} +0 -0
@@ -0,0 +1,304 @@
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.dismissKeyboard(opts?)` | Platform-aware keyboard dismissal |
70
+ | `app.swipe(direction, opts?)` | Swipe: "up"/"down"/"left"/"right" |
71
+ | `app.scroll(direction)` | Scroll (slower swipe) |
72
+ | `app.scrollUntilVisible(sel)` | Scroll until target is visible |
73
+ | `app.launch(opts?)` | Launch/relaunch app |
74
+ | `app.stop()` / `app.kill()` | Stop or force-kill app |
75
+ | `app.clearState()` | Clear app data |
76
+ | `app.openLink(url)` | Open deep link or URL |
77
+ | `app.back()` | Navigate back |
78
+ | `app.backUntilVisible(sel)` | Back until target is visible |
79
+ | `app.takeScreenshot(name?)` | Capture screenshot |
80
+ | `app.evaluate(fn, ...args)` | Run JS in web context |
81
+
82
+ `opts` on tap/doubleTap/longPress accepts `{ timeout?: number }` to override wait timeout.
83
+
84
+ ### expect methods (FlowContext.expect)
85
+
86
+ ```ts
87
+ await expect({ testID: "header" }).toBeVisible();
88
+ await expect({ testID: "header" }).toBeVisible({ timeout: 10_000 });
89
+ await expect({ testID: "spinner" }).toBeHidden();
90
+ await expect({ testID: "title" }).toHaveText("Welcome");
91
+ ```
92
+
93
+ | Method | Description |
94
+ | ----------------------------- | ------------------------------------- |
95
+ | `toBeVisible(opts?)` | Assert element is visible on screen |
96
+ | `toBeHidden(opts?)` | Assert element is not visible |
97
+ | `toHaveText(expected, opts?)` | Assert element's text matches exactly |
98
+
99
+ All expect methods auto-wait with polling. Pass `{ timeout: ms }` to override.
100
+
101
+ ### Selector types
102
+
103
+ ```ts
104
+ { testID: "login-btn" } // maps to data-testid (web), resource-id (Android), accessibilityIdentifier (iOS)
105
+ { text: "Sign In" } // visible label text
106
+ { accessibilityLabel: "Close" } // OS accessibility label
107
+ { point: { x: 100, y: 200 } } // absolute coordinate (last resort)
108
+ "Sign In" // shorthand for { text: "Sign In" }
109
+ ```
110
+
111
+ **Selector priority:** `testID` > `accessibilityLabel` > `text` > `point`
112
+
113
+ **Relative selectors** (for ambiguous elements):
114
+
115
+ ```ts
116
+ await app.tap({ selector: { text: "Edit" }, below: { testID: "user-row-1" } });
117
+ await app.tap({ selector: { text: "Delete" }, rightOf: { text: "Item 3" } });
118
+ ```
119
+
120
+ Relative modifiers: `below`, `above`, `leftOf`, `rightOf`, `childOf`.
121
+
122
+ ### Validate without a device
123
+
124
+ ```bash
125
+ spana validate # validates all flows in flowDir
126
+ spana validate flows/ # validate specific directory
127
+ ```
128
+
129
+ Checks: valid exports, no duplicate names, valid platform values, directory exists.
130
+
131
+ ### Run and read results
132
+
133
+ ```bash
134
+ spana test --platform web --reporter json
135
+ spana test flows/login.flow.ts --reporter json
136
+ spana test --tag smoke --platform android --reporter json
137
+ spana test --grep "login" --reporter json
138
+
139
+ # Parse failures
140
+ spana test --reporter json 2>&1 | jq '.results[] | select(.status == "failed")'
141
+ ```
142
+
143
+ ## Agent workflow loop
144
+
145
+ ```
146
+ 1. spana selectors --platform <target> -> discover elements
147
+ 2. Write a .flow.ts file using selectors -> create the test
148
+ 3. spana validate flows/ -> check structure (no device needed)
149
+ 4. spana test <file> --reporter json -> execute on device
150
+ 5. If failed: read error, fix, goto 3
151
+ ```
152
+
153
+ Do not skip step 3. Validation catches export errors, duplicate names, and invalid platforms before spending device time.
154
+
155
+ ## Flow patterns
156
+
157
+ ### Navigation with deep links
158
+
159
+ ```ts
160
+ export default flow(
161
+ "home screen loads",
162
+ { autoLaunch: false },
163
+ async ({ app, expect, platform }) => {
164
+ const url = platform === "web" ? "http://localhost:3000/" : "myapp://home";
165
+ await app.openLink(url);
166
+ await expect({ testID: "home-screen" }).toBeVisible();
167
+ },
168
+ );
169
+ ```
170
+
171
+ ### Form fill
172
+
173
+ ```ts
174
+ await app.tap({ testID: "email-input" });
175
+ await app.inputText("user@example.com");
176
+ await app.tap({ testID: "password-input" });
177
+ await app.inputText("secret123");
178
+ await app.dismissKeyboard();
179
+ await app.tap({ testID: "submit-btn" });
180
+ await expect({ testID: "dashboard" }).toBeVisible();
181
+ ```
182
+
183
+ ### Scrolling to find content
184
+
185
+ ```ts
186
+ await app.scroll("down");
187
+ await expect({ testID: "footer-section" }).toBeVisible({ timeout: 10_000 });
188
+ ```
189
+
190
+ ### Platform branching
191
+
192
+ ```ts
193
+ async ({ app, expect, platform }) => {
194
+ await app.tap({ testID: "menu-btn" });
195
+ if (platform === "android") {
196
+ await app.back(); // close drawer via back button
197
+ }
198
+ if (platform === "web") {
199
+ await app.evaluate(() => window.scrollTo(0, 0));
200
+ }
201
+ };
202
+ ```
203
+
204
+ ### Artifact capture per flow
205
+
206
+ ```ts
207
+ export default flow(
208
+ "checkout flow",
209
+ { artifacts: { captureOnSuccess: true, captureSteps: true } },
210
+ async ({ app, expect }) => {
211
+ /* ... */
212
+ },
213
+ );
214
+ ```
215
+
216
+ ## Platform-specific notes
217
+
218
+ ### Web
219
+
220
+ - Uses Playwright (CDP). No companion binary needed.
221
+ - `testID` maps to `data-testid` attribute.
222
+ - `app.evaluate()` runs JS in the browser context.
223
+ - Default `baseUrl`: `http://localhost:3000`.
224
+
225
+ ### Android
226
+
227
+ - Uses UiAutomator2 HTTP server (APK auto-installed on device).
228
+ - `testID` maps to `resource-id`.
229
+ - `app.back()` triggers the system back button.
230
+ - Emulators and physical devices supported.
231
+
232
+ ### iOS
233
+
234
+ - Uses WebDriverAgent (XCTest bundle).
235
+ - `testID` maps to `accessibilityIdentifier`.
236
+ - Simulators: works out of the box.
237
+ - Physical devices: requires code signing config in `spana.config.ts`.
238
+ - `app.back()` may not work the same as Android; prefer tap on back button element.
239
+
240
+ ## Error handling
241
+
242
+ | Error | Cause | Fix |
243
+ | ----------------------------- | -------------------------------------------- | ----------------------------------------------------------------------- |
244
+ | `Element not found: {...}` | Selector does not match any visible element | Run `spana selectors` to verify element exists and get correct selector |
245
+ | `Timeout waiting for element` | Element didn't appear within wait timeout | Increase `timeout` in opts, or check if prior navigation succeeded |
246
+ | `Duplicate flow name` | Two flow files export the same `name` string | Rename one of the flows |
247
+ | `Invalid platform` | Platform string is not web/android/ios | Fix the `platforms` array in FlowConfig |
248
+ | `No Android device connected` | No emulator/device available | Start emulator or connect device, verify with `spana devices` |
249
+ | `No iOS simulator available` | No booted simulator found | Boot a simulator: `xcrun simctl boot <udid>` |
250
+
251
+ 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.
252
+
253
+ ## Config reference
254
+
255
+ `spana.config.ts` at project root:
256
+
257
+ ```ts
258
+ import { defineConfig } from "spana-test";
259
+
260
+ export default defineConfig({
261
+ apps: {
262
+ web: { url: "http://localhost:3000" },
263
+ android: { packageName: "com.example.app" },
264
+ ios: { bundleId: "com.example.app", appPath: "./MyApp.app" },
265
+ },
266
+ platforms: ["web", "android", "ios"],
267
+ flowDir: "./flows",
268
+ reporters: ["console", "json", "html"],
269
+ defaults: {
270
+ waitTimeout: 5000, // ms to wait for element visibility
271
+ pollInterval: 200, // ms between hierarchy polls
272
+ settleTimeout: 300, // ms of stability before match
273
+ retries: 2, // retries on action failure
274
+ },
275
+ artifacts: {
276
+ outputDir: ".spana/artifacts",
277
+ captureOnFailure: true,
278
+ captureOnSuccess: false,
279
+ screenshot: true,
280
+ uiHierarchy: true,
281
+ },
282
+ hooks: {
283
+ beforeAll: async ({ app }) => {
284
+ /* global setup */
285
+ },
286
+ beforeEach: async ({ app }) => {
287
+ /* per-flow setup, e.g. clear state */
288
+ },
289
+ afterEach: async ({ app, result }) => {
290
+ /* per-flow teardown */
291
+ },
292
+ afterAll: async ({ app, summary }) => {
293
+ /* global cleanup */
294
+ },
295
+ },
296
+ });
297
+ ```
298
+
299
+ Key config options for agents:
300
+
301
+ - `flowDir`: where to put flow files (default `./flows`)
302
+ - `defaults.waitTimeout`: how long auto-wait polls before failing
303
+ - `artifacts.captureOnFailure`: auto-capture screenshots on failure (useful for debugging)
304
+ - `reporters`: use `["json"]` for machine-readable output