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.
- package/.agents/skills/spana-testing/SKILL.md +126 -246
- package/README.md +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +5 -5
- package/dist/{storybook-CxaP3YDz.d.ts → app-D_UyZBsl.d.ts} +213 -10
- package/dist/{chunk-WSA5QPTA.js → chunk-2IXXEXTL.js} +2 -2
- package/dist/{chunk-3YE2POGD.js → chunk-3SH5JQF7.js} +143 -3
- package/dist/chunk-3SH5JQF7.js.map +1 -0
- package/dist/chunk-54ASKII6.js +183 -0
- package/dist/chunk-54ASKII6.js.map +1 -0
- package/dist/{chunk-LRGT342X.js → chunk-6B5Y75V4.js} +1633 -533
- package/dist/chunk-6B5Y75V4.js.map +1 -0
- package/dist/{chunk-SQL3YRR5.js → chunk-JYFPZRCN.js} +21 -3
- package/dist/chunk-JYFPZRCN.js.map +1 -0
- package/dist/{chunk-UJQ7PID5.js → chunk-KNSAHEXI.js} +78 -3
- package/dist/chunk-KNSAHEXI.js.map +1 -0
- package/dist/{chunk-3TRMQCUT.js → chunk-PLE7RFQE.js} +31 -2
- package/dist/chunk-PLE7RFQE.js.map +1 -0
- package/dist/{chunk-H3RWZCID.js → chunk-RURZVMZ7.js} +104 -3
- package/dist/chunk-RURZVMZ7.js.map +1 -0
- package/dist/{chunk-XENRC3YO.js → chunk-T3EBOYLS.js} +751 -59
- package/dist/chunk-T3EBOYLS.js.map +1 -0
- package/dist/{chunk-PJKIXVSO.js → chunk-T5CROOR7.js} +898 -238
- package/dist/chunk-T5CROOR7.js.map +1 -0
- package/dist/{chunk-5245YBLL.js → chunk-Y2RZNOKU.js} +2 -2
- package/dist/cli.js +11 -11
- package/dist/cli.js.map +1 -1
- package/dist/config-loader-NIDQGP3K.js +9 -0
- package/dist/{doctor-command-WB3O2H64.js → doctor-command-WPEVZEZ4.js} +3 -3
- package/dist/{filters-Q3ALKWZ5.js → filters-MQG2RMPX.js} +4 -2
- package/dist/flow-g6AICPAl.d.ts +95 -0
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/{html-F3X3XPSX.js → html-IKCTZH2U.js} +194 -3
- package/dist/html-IKCTZH2U.js.map +1 -0
- package/dist/index.d.ts +436 -21
- package/dist/index.js +328 -7
- package/dist/index.js.map +1 -1
- package/dist/{runner-6HK62Q7B.js → runner-TF4OKPYP.js} +2 -2
- package/dist/{screenshot-compare-3QRHHSFZ.js → screenshot-compare-POTXVUTL.js} +21 -1
- package/dist/screenshot-compare-POTXVUTL.js.map +1 -0
- package/dist/{server-PRM7BVVD.js → server-EBPYK3VE.js} +5 -5
- package/dist/{server-QWJJB3WG.js → server-IGLBFEU7.js} +2 -2
- package/dist/{session-2E6OK6BH.js → session-QRWH3SPW.js} +4 -4
- package/dist/{session-Ddem-Q5n.d.ts → session-cJ_tZjCL.d.ts} +22 -1
- package/dist/{studio-command-O3NN5BCG.js → studio-command-FLA5HKRK.js} +2 -2
- package/dist/{test-command-FYOZ6QAE.js → test-command-P5W7UD52.js} +24 -10
- package/dist/test-command-P5W7UD52.js.map +1 -0
- package/dist/{validator-HZ2A3NEI.js → validator-BLOLIHUY.js} +3 -3
- package/package.json +3 -2
- package/dist/chunk-3TRMQCUT.js.map +0 -1
- package/dist/chunk-3YE2POGD.js.map +0 -1
- package/dist/chunk-H3RWZCID.js.map +0 -1
- package/dist/chunk-LRGT342X.js.map +0 -1
- package/dist/chunk-PJKIXVSO.js.map +0 -1
- package/dist/chunk-SQL3YRR5.js.map +0 -1
- package/dist/chunk-UJQ7PID5.js.map +0 -1
- package/dist/chunk-XENRC3YO.js.map +0 -1
- package/dist/config-loader-XGDDJGVY.js +0 -9
- package/dist/flow-CyRC-tTc.d.ts +0 -176
- package/dist/html-F3X3XPSX.js.map +0 -1
- package/dist/screenshot-compare-3QRHHSFZ.js.map +0 -1
- package/dist/test-command-FYOZ6QAE.js.map +0 -1
- /package/dist/{chunk-WSA5QPTA.js.map → chunk-2IXXEXTL.js.map} +0 -0
- /package/dist/{chunk-5245YBLL.js.map → chunk-Y2RZNOKU.js.map} +0 -0
- /package/dist/{config-loader-XGDDJGVY.js.map → config-loader-NIDQGP3K.js.map} +0 -0
- /package/dist/{doctor-command-WB3O2H64.js.map → doctor-command-WPEVZEZ4.js.map} +0 -0
- /package/dist/{filters-Q3ALKWZ5.js.map → filters-MQG2RMPX.js.map} +0 -0
- /package/dist/{runner-6HK62Q7B.js.map → runner-TF4OKPYP.js.map} +0 -0
- /package/dist/{server-PRM7BVVD.js.map → server-EBPYK3VE.js.map} +0 -0
- /package/dist/{server-QWJJB3WG.js.map → server-IGLBFEU7.js.map} +0 -0
- /package/dist/{session-2E6OK6BH.js.map → session-QRWH3SPW.js.map} +0 -0
- /package/dist/{studio-command-O3NN5BCG.js.map → studio-command-FLA5HKRK.js.map} +0 -0
- /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
|
|
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
|
-
|
|
7
|
+
Full online docs & LLM reference: `https://spana.antonwester.se/llms-full.txt`
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
---
|
|
10
10
|
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
28
|
+
---
|
|
26
29
|
|
|
27
|
-
|
|
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
|
-
|
|
126
|
-
spana
|
|
127
|
-
```
|
|
33
|
+
# 1. Check environment readiness (web, Android/iOS WebView, WDA/UA2, Electron, Electrobun)
|
|
34
|
+
spana doctor --json
|
|
128
35
|
|
|
129
|
-
|
|
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
|
-
|
|
42
|
+
# 3. Validate flows without a device/browser
|
|
43
|
+
spana validate-config
|
|
44
|
+
spana validate flows/
|
|
132
45
|
|
|
133
|
-
|
|
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 --
|
|
137
|
-
spana test --
|
|
138
|
-
|
|
139
|
-
#
|
|
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
|
-
|
|
147
|
-
|
|
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
|
-
|
|
58
|
+
---
|
|
154
59
|
|
|
155
|
-
##
|
|
60
|
+
## Writing Flows
|
|
156
61
|
|
|
157
|
-
###
|
|
62
|
+
### Standard `.flow.ts`
|
|
158
63
|
|
|
159
64
|
```ts
|
|
65
|
+
import { flow, systemUI } from "spana-test";
|
|
66
|
+
|
|
160
67
|
export default flow(
|
|
161
|
-
"
|
|
162
|
-
{
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
###
|
|
80
|
+
### Composable Lazy Fixtures & Named Setups
|
|
172
81
|
|
|
173
82
|
```ts
|
|
174
|
-
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
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
|
-
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
"
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
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
|
-
|
|
302
|
-
- `
|
|
303
|
-
|
|
304
|
-
|
|
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>
|
|
8
|
+
<strong>One test. Every screen.</strong><br />TypeScript E2E testing for Web, iOS & 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
|
|
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 |
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { C as ConnectOptions, D as Direction, S as Session, a as SuggestedSelector, c as connect } from '../session-
|
|
2
|
-
import '../
|
|
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 {
|
package/dist/agent/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
validateFlows
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-Y2RZNOKU.js";
|
|
4
|
+
import "../chunk-PLE7RFQE.js";
|
|
5
5
|
import {
|
|
6
6
|
Session,
|
|
7
7
|
connect
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-KNSAHEXI.js";
|
|
9
9
|
import "../chunk-HCG4CJKR.js";
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
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";
|