spana-test 0.5.0 → 0.7.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 (73) hide show
  1. package/.agents/skills/spana-testing/SKILL.md +126 -246
  2. package/README.md +2 -2
  3. package/dist/agent/index.d.ts +2 -2
  4. package/dist/agent/index.js +5 -5
  5. package/dist/{storybook-CxaP3YDz.d.ts → app-D_UyZBsl.d.ts} +213 -10
  6. package/dist/{chunk-WSA5QPTA.js → chunk-2IXXEXTL.js} +2 -2
  7. package/dist/{chunk-3YE2POGD.js → chunk-3SH5JQF7.js} +143 -3
  8. package/dist/chunk-3SH5JQF7.js.map +1 -0
  9. package/dist/chunk-54ASKII6.js +183 -0
  10. package/dist/chunk-54ASKII6.js.map +1 -0
  11. package/dist/{chunk-LRGT342X.js → chunk-6B5Y75V4.js} +1633 -533
  12. package/dist/chunk-6B5Y75V4.js.map +1 -0
  13. package/dist/{chunk-SQL3YRR5.js → chunk-JYFPZRCN.js} +21 -3
  14. package/dist/chunk-JYFPZRCN.js.map +1 -0
  15. package/dist/{chunk-UJQ7PID5.js → chunk-KNSAHEXI.js} +78 -3
  16. package/dist/chunk-KNSAHEXI.js.map +1 -0
  17. package/dist/{chunk-3TRMQCUT.js → chunk-PLE7RFQE.js} +31 -2
  18. package/dist/chunk-PLE7RFQE.js.map +1 -0
  19. package/dist/{chunk-H3RWZCID.js → chunk-RURZVMZ7.js} +104 -3
  20. package/dist/chunk-RURZVMZ7.js.map +1 -0
  21. package/dist/{chunk-XENRC3YO.js → chunk-T3EBOYLS.js} +751 -59
  22. package/dist/chunk-T3EBOYLS.js.map +1 -0
  23. package/dist/{chunk-PJKIXVSO.js → chunk-T5CROOR7.js} +898 -238
  24. package/dist/chunk-T5CROOR7.js.map +1 -0
  25. package/dist/{chunk-5245YBLL.js → chunk-Y2RZNOKU.js} +2 -2
  26. package/dist/cli.js +11 -11
  27. package/dist/cli.js.map +1 -1
  28. package/dist/config-loader-NIDQGP3K.js +9 -0
  29. package/dist/{doctor-command-WB3O2H64.js → doctor-command-WPEVZEZ4.js} +3 -3
  30. package/dist/{filters-Q3ALKWZ5.js → filters-MQG2RMPX.js} +4 -2
  31. package/dist/flow-g6AICPAl.d.ts +95 -0
  32. package/dist/gherkin/steps.d.ts +2 -2
  33. package/dist/{html-F3X3XPSX.js → html-IKCTZH2U.js} +194 -3
  34. package/dist/html-IKCTZH2U.js.map +1 -0
  35. package/dist/index.d.ts +436 -21
  36. package/dist/index.js +328 -7
  37. package/dist/index.js.map +1 -1
  38. package/dist/{runner-6HK62Q7B.js → runner-TF4OKPYP.js} +2 -2
  39. package/dist/{screenshot-compare-3QRHHSFZ.js → screenshot-compare-POTXVUTL.js} +21 -1
  40. package/dist/screenshot-compare-POTXVUTL.js.map +1 -0
  41. package/dist/{server-PRM7BVVD.js → server-EBPYK3VE.js} +5 -5
  42. package/dist/{server-QWJJB3WG.js → server-IGLBFEU7.js} +2 -2
  43. package/dist/{session-2E6OK6BH.js → session-QRWH3SPW.js} +4 -4
  44. package/dist/{session-Ddem-Q5n.d.ts → session-cJ_tZjCL.d.ts} +22 -1
  45. package/dist/{studio-command-O3NN5BCG.js → studio-command-FLA5HKRK.js} +2 -2
  46. package/dist/{test-command-FYOZ6QAE.js → test-command-P5W7UD52.js} +24 -10
  47. package/dist/test-command-P5W7UD52.js.map +1 -0
  48. package/dist/{validator-HZ2A3NEI.js → validator-BLOLIHUY.js} +3 -3
  49. package/package.json +3 -2
  50. package/dist/chunk-3TRMQCUT.js.map +0 -1
  51. package/dist/chunk-3YE2POGD.js.map +0 -1
  52. package/dist/chunk-H3RWZCID.js.map +0 -1
  53. package/dist/chunk-LRGT342X.js.map +0 -1
  54. package/dist/chunk-PJKIXVSO.js.map +0 -1
  55. package/dist/chunk-SQL3YRR5.js.map +0 -1
  56. package/dist/chunk-UJQ7PID5.js.map +0 -1
  57. package/dist/chunk-XENRC3YO.js.map +0 -1
  58. package/dist/config-loader-XGDDJGVY.js +0 -9
  59. package/dist/flow-CyRC-tTc.d.ts +0 -176
  60. package/dist/html-F3X3XPSX.js.map +0 -1
  61. package/dist/screenshot-compare-3QRHHSFZ.js.map +0 -1
  62. package/dist/test-command-FYOZ6QAE.js.map +0 -1
  63. /package/dist/{chunk-WSA5QPTA.js.map → chunk-2IXXEXTL.js.map} +0 -0
  64. /package/dist/{chunk-5245YBLL.js.map → chunk-Y2RZNOKU.js.map} +0 -0
  65. /package/dist/{config-loader-XGDDJGVY.js.map → config-loader-NIDQGP3K.js.map} +0 -0
  66. /package/dist/{doctor-command-WB3O2H64.js.map → doctor-command-WPEVZEZ4.js.map} +0 -0
  67. /package/dist/{filters-Q3ALKWZ5.js.map → filters-MQG2RMPX.js.map} +0 -0
  68. /package/dist/{runner-6HK62Q7B.js.map → runner-TF4OKPYP.js.map} +0 -0
  69. /package/dist/{server-PRM7BVVD.js.map → server-EBPYK3VE.js.map} +0 -0
  70. /package/dist/{server-QWJJB3WG.js.map → server-IGLBFEU7.js.map} +0 -0
  71. /package/dist/{session-2E6OK6BH.js.map → session-QRWH3SPW.js.map} +0 -0
  72. /package/dist/{studio-command-O3NN5BCG.js.map → studio-command-FLA5HKRK.js.map} +0 -0
  73. /package/dist/{validator-HZ2A3NEI.js.map → validator-BLOLIHUY.js.map} +0 -0
@@ -2,303 +2,183 @@
2
2
 
3
3
  ## When to use
4
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.
5
+ Use this skill when setting up, writing, debugging, or iterating on **spana (`spana-test`)** E2E tests across **Web, Android (Capacitor/WebView & React Native), iOS (WKWebView & React Native), Electron, and Electrobun**. Spana uses pure TypeScript `flow()` files (plus optional Gherkin `.feature` files) with a dual-channel web-first engine — zero Appium required locally.
6
6
 
7
- ## Quick reference
7
+ Full online docs & LLM reference: `https://spana.antonwester.se/llms-full.txt`
8
8
 
9
- ### Discover elements on screen
9
+ ---
10
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
- ```
11
+ ## Preferred Agent Workflow: `spana mcp` (Model-Free Stdio MCP Server)
17
12
 
18
- Filter with `jq`:
13
+ When connected to `spana mcp` (`npx spana mcp` / `bunx spana mcp`), drive live sessions directly at sub-5 ms tool latency instead of shelling out repeatedly:
19
14
 
20
- ```bash
21
- spana selectors --platform web | jq '.[] | select(.testID != null)'
22
- spana selectors --platform ios | jq '[.[].suggestedSelector]'
23
- ```
15
+ | MCP Tool | Purpose |
16
+ | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
17
+ | `spana_session_start` | Start a live session (`web`, `android`, `ios`, `electron`, `electrobun`) |
18
+ | `spana_observe` | Compact interactive element tree (~273 tokens avg) with `testID` & bounds |
19
+ | `spana_tap` / `spana_fill` / `spana_input_text` / `spana_press_key` | Execute verified pointer/keyboard actions (1-RTT atomic `spana_fill` + 2–4 ms tap) |
20
+ | `spana_assert_visible` / `spana_assert_text` | Run real auto-waiting assertions (~1 ms on web) |
21
+ | `spana_assert_accessible` | Run live `axe-core` WCAG accessibility audit on the current screen |
22
+ | `spana_assert_screenshot` | Run Rust-accelerated visual regression diff against saved baselines |
23
+ | `spana_diagnostics` | Fetch browser console logs & uncaught JS errors (~0.8 ms) |
24
+ | `spana_screenshot` | Capture PNG screenshot when visual inspection is needed |
25
+ | `spana_export_flow` | Export the verified action trace as a deterministic `.flow.ts` file |
26
+ | `spana_run_flow` / `spana_session_stop` | Execute existing `.flow.ts` files and cleanly tear down |
24
27
 
25
- ### Write a flow
28
+ ---
26
29
 
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
30
+ ## CLI Discovery & Execution Loop
123
31
 
124
32
  ```bash
125
- spana validate # validates all flows in flowDir
126
- spana validate flows/ # validate specific directory
127
- ```
33
+ # 1. Check environment readiness (web, Android/iOS WebView, WDA/UA2, Electron, Electrobun)
34
+ spana doctor --json
128
35
 
129
- Checks: valid exports, no duplicate names, valid platform values, directory exists.
36
+ # 2. Discover interactable elements with suggested selectors
37
+ spana selectors --platform web
38
+ spana selectors --platform android
39
+ spana selectors --platform ios
40
+ spana hierarchy --platform web --pretty
130
41
 
131
- ### Run and read results
42
+ # 3. Validate flows without a device/browser
43
+ spana validate-config
44
+ spana validate flows/
132
45
 
133
- ```bash
134
- spana test --platform web --reporter json
46
+ # 4. Run tests (fast parallel + structured output)
135
47
  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
48
+ spana test --platform web --parallel --workers 4
49
+ spana test --changed-since origin/main --reporter console,github
50
+ spana test --last-failed
51
+ spana test --strict-cache # 0-LLM verified replay cache in CI
144
52
 
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
53
+ # 5. Manage persistent warm daemons (Chromium / WDA / UiAutomator2)
54
+ spana daemon status
55
+ spana daemon stop
151
56
  ```
152
57
 
153
- Do not skip step 3. Validation catches export errors, duplicate names, and invalid platforms before spending device time.
58
+ ---
154
59
 
155
- ## Flow patterns
60
+ ## Writing Flows
156
61
 
157
- ### Navigation with deep links
62
+ ### Standard `.flow.ts`
158
63
 
159
64
  ```ts
65
+ import { flow, systemUI } from "spana-test";
66
+
160
67
  export default flow(
161
- "home screen loads",
162
- { autoLaunch: false },
68
+ "SSO sign-in across WebView and native sheet",
69
+ { tags: ["smoke", "auth"], platforms: ["web", "android", "ios"], timeout: 30_000 },
163
70
  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();
71
+ await app.tap({ testID: "sign-in" }); // ~1 ms DOM lookup -> real native touch
72
+ if (platform !== "web") {
73
+ await app.tap(systemUI({ text: "Continue" })); // SFSafariViewController / Chrome Custom Tabs
74
+ }
75
+ await expect({ testID: "profile-id" }).toBeVisible();
167
76
  },
168
77
  );
169
78
  ```
170
79
 
171
- ### Form fill
80
+ ### Composable Lazy Fixtures & Named Setups
172
81
 
173
82
  ```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
- ```
83
+ import { createFlowWithFixtures, defineSetup } from "spana-test";
189
84
 
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
- ```
85
+ const adminSetup = defineSetup("admin", {
86
+ storage: { localStorage: { auth_token: "test-admin-jwt" } },
87
+ });
203
88
 
204
- ### Artifact capture per flow
89
+ const testFlow = createFlowWithFixtures({
90
+ setups: { admin: adminSetup },
91
+ fixtures: {
92
+ seededOrder: async ({ app }, use) => {
93
+ const orderId = "ord_123";
94
+ await use(orderId);
95
+ },
96
+ },
97
+ });
205
98
 
206
- ```ts
207
- export default flow(
208
- "checkout flow",
209
- { artifacts: { captureOnSuccess: true, captureSteps: true } },
210
- async ({ app, expect }) => {
211
- /* ... */
99
+ export default testFlow(
100
+ "admin inspects order",
101
+ { setup: "admin" },
102
+ async ({ app, expect, seededOrder }) => {
103
+ await app.openLink(`/orders/${seededOrder}`);
104
+ await expect({ testID: "order-status" }).toContainText("Paid");
212
105
  },
213
106
  );
214
107
  ```
215
108
 
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
109
+ ---
226
110
 
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.
111
+ ## Selector Priority & Dual-Channel Rules
231
112
 
232
- ### iOS
113
+ 1. **`{ testID: "..." }`** (preferred) — maps to `data-testid` / `testID` (Web, Shadow DOM, same-origin `<iframe>`, Capacitor WebView, Electron, Electrobun), `resource-id` (Android), and `accessibilityIdentifier` (iOS).
114
+ 2. **`systemUI({ text: "..." })` / `systemUI({ accessibilityLabel: "..." })`** — routes straight to native OS UI (permission sheets, OAuth `SFSafariViewController`, Chrome Custom Tabs) and skips DOM channels.
115
+ 3. **`{ accessibilityLabel: "..." }`** — OS accessibility label / `aria-label`.
116
+ 4. **`{ text: "..." }`** — visible text match.
117
+ 5. **Relative selectors:** `{ selector: { text: "Edit" }, below: { testID: "user-row-1" } }` (`below`, `above`, `leftOf`, `rightOf`, `childOf`).
118
+ 6. **`{ point: { x, y } }`** — last resort only.
233
119
 
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.
120
+ ### Common `app` & `expect` APIs
239
121
 
240
- ## Error handling
122
+ - **Actions:** `app.tap()`, `app.doubleTap()`, `app.longPress()`, `app.inputText()`, `app.pressKey()`, `app.dismissKeyboard()`, `app.scrollUntilVisible()`, `app.backUntilVisible()`, `app.openLink()`, `app.takeScreenshot()`, `app.evaluate()`
123
+ - **Web helpers:** `app.mockNetwork()`, `app.blockNetwork()`, `app.setNetworkConditions()`, `app.saveAuthState()`, `app.loadAuthState()`, `app.getConsoleLogs()`, `app.getJSErrors()`, `app.openStory()`
124
+ - **Assertions (auto-waiting with MutationObserver reactive waits on web):** `toBeVisible()`, `toBeHidden()`, `toHaveText()`, `toContainText()`, `toMatchText()`, `toHaveValue()`, `toBeEnabled()`, `toBeDisabled()`, `toHaveAttribute()`, `toMatchScreenshot({ mode: "layout-tolerant" })`, `toPassAccessibilityAudit()`
241
125
 
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>` |
126
+ ---
250
127
 
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:
128
+ ## Fast Configuration & CI Filters (`spana.config.ts`)
256
129
 
257
130
  ```ts
258
- import { defineConfig } from "spana-test";
131
+ import {
132
+ defineConfig,
133
+ decisionFilter,
134
+ createLogprobDecisionJudge,
135
+ pathRuleFilter,
136
+ } from "spana-test";
259
137
 
260
138
  export default defineConfig({
261
139
  apps: {
262
140
  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
141
+ android: { packageName: "com.example.app", appPath: "./builds/app.apk" },
142
+ ios: { bundleId: "com.example.app", appPath: "./builds/MyApp.app" },
274
143
  },
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 */
144
+ execution: {
145
+ web: {
146
+ browser: "chromium", // or engine: "cdp" | "lightpanda" with cdpUrl, or wsEndpoint for BrowserStack Automate Web
147
+ headless: true,
148
+ warmBrowser: true,
149
+ instantAnimations: true,
150
+ blockResources: ["image", "font", "media"],
294
151
  },
295
152
  },
153
+ defaults: {
154
+ waitTimeout: 5000,
155
+ failFastWhenIdle: false, // set true on web to fail missing selectors once page is idle
156
+ },
157
+ filters: [
158
+ pathRuleFilter({
159
+ rules: [{ matchFlow: { tag: "billing" }, watchPaths: ["src/billing/"] }],
160
+ }),
161
+ decisionFilter({
162
+ alwaysRunTags: ["smoke"],
163
+ judge: createLogprobDecisionJudge({
164
+ provider: "openai",
165
+ baseUrl: "http://127.0.0.1:8000/v1",
166
+ model: "typesafe-ai/jev",
167
+ }),
168
+ }),
169
+ ],
170
+ reporters: ["console", "html"],
296
171
  });
297
172
  ```
298
173
 
299
- Key config options for agents:
174
+ ---
175
+
176
+ ## Failure Investigation & Fixing Application Bugs
177
+
178
+ When a flow fails, decide first whether the bug is in the **test** or in the **application under test** — never paper over real app bugs with `sleep()` or loosened assertions:
300
179
 
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
180
+ 1. **Inspect `failure-bundle.json` and `report.html` playback** in `.spana/artifacts/` (or `spana-output/`): check the visual timeline frames + click-ripple position, failed step, nearby selectors, inline `consoleLogs`, and uncaught `jsErrors`.
181
+ 2. **Fix missing `data-testid` / `testID` in the app** when an interactive control has no stable selector (`spana_observe` shows unlabelled buttons/inputs) — add `data-testid` to the component rather than relying on fragile text/coordinate selectors.
182
+ 3. **Fix hydration / overlay races in the app** when taps wait on obscured overlays or fire before client state boots — set `window.__SPANA_APP_READY__ = true` once hydration/auth settles (Spana automatically awaits it) and guard async tab/filter fetches with `AbortController` or a request sequence counter so stale responses cannot overwrite newer UI state.
183
+ 4. **Fix accessibility violations in the app** when `spana_assert_accessible` / `toPassAccessibilityAudit()` reports WCAG failures — repair missing `aria-label`s, `<label htmlFor>`, button semantics, and color contrast in the component source rather than excluding rules.
184
+ 5. **Eliminate flaky test setup** — use `app.fill()` (atomic 1-RTT clear+type), `definePersona()` / `PersonaAuthCache` / `createApiFixture()` instead of repeated UI login, `execution.web.engine: "auto"` (Direct CDP with automatic OOPIF iframe support), `artifacts.video: "retain-on-failure"` + `artifacts.playback: true` for visual debugging, and always run `spana validate` before `spana test`.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <h1 align="center">spana</h1>
6
6
 
7
7
  <p align="center">
8
- <strong>Web-first, TypeScript-native E2E testing across Web, Capacitor/React Native (iOS &amp; Android), Electron, and Electrobun — one <code>{ testID }</code> selector model, zero Appium required.</strong>
8
+ <strong>One test. Every screen.</strong><br />TypeScript E2E testing for Web, iOS &amp; Android (Capacitor / React Native), Electron, and Electrobun — one <code>{ testID }</code> selector, no Appium to set up, and an MCP server your coding agent can drive.
9
9
  </p>
10
10
 
11
11
  <p align="center">
@@ -613,7 +613,7 @@ See [ARCHITECTURE.md](https://github.com/wezter96/spana/blob/main/ARCHITECTURE.m
613
613
  ## Platforms
614
614
 
615
615
  <p align="center">
616
- <img src="https://raw.githubusercontent.com/wezter96/spana/main/docs/assets/spana-hero.jpg" alt="One selector model fanning out to Web, iOS, Android, Electron, and Electrobun" width="100%" />
616
+ <img src="https://raw.githubusercontent.com/wezter96/spana/main/docs/assets/spana-hero.jpg" alt="One test fanning out to Web, iOS, Android, Electron, and Electrobun" width="100%" />
617
617
  </p>
618
618
 
619
619
  | Platform | Driver / DOM Channel | Companion binary |
@@ -1,5 +1,5 @@
1
- export { C as ConnectOptions, D as Direction, S as Session, a as SuggestedSelector, c as connect } from '../session-Ddem-Q5n.js';
2
- import '../storybook-CxaP3YDz.js';
1
+ export { C as ConnectOptions, D as Direction, S as Session, a as SuggestedSelector, c as connect } from '../session-cJ_tZjCL.js';
2
+ import '../app-D_UyZBsl.js';
3
3
  import 'effect';
4
4
 
5
5
  interface ValidationError {
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  validateFlows
3
- } from "../chunk-5245YBLL.js";
4
- import "../chunk-3TRMQCUT.js";
3
+ } from "../chunk-Y2RZNOKU.js";
4
+ import "../chunk-PLE7RFQE.js";
5
5
  import {
6
6
  Session,
7
7
  connect
8
- } from "../chunk-UJQ7PID5.js";
8
+ } from "../chunk-KNSAHEXI.js";
9
9
  import "../chunk-HCG4CJKR.js";
10
- import "../chunk-PJKIXVSO.js";
11
- import "../chunk-XENRC3YO.js";
10
+ import "../chunk-T5CROOR7.js";
11
+ import "../chunk-T3EBOYLS.js";
12
12
  import "../chunk-HYSTRWYN.js";
13
13
  import "../chunk-DTNK54C2.js";
14
14
  import "../chunk-S5JNNDXS.js";