spana-test 0.5.0 → 0.6.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 +122 -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-DcLXtpv4.d.ts} +205 -9
- package/dist/{chunk-3YE2POGD.js → chunk-3SH5JQF7.js} +143 -3
- package/dist/chunk-3SH5JQF7.js.map +1 -0
- package/dist/chunk-4K3FZTSV.js +179 -0
- package/dist/chunk-4K3FZTSV.js.map +1 -0
- package/dist/{chunk-H3RWZCID.js → chunk-C4E4XULT.js} +104 -3
- package/dist/chunk-C4E4XULT.js.map +1 -0
- package/dist/{chunk-SQL3YRR5.js → chunk-KBRLIQRA.js} +16 -1
- package/dist/chunk-KBRLIQRA.js.map +1 -0
- package/dist/{chunk-LRGT342X.js → chunk-KEUZLBQS.js} +1110 -475
- package/dist/chunk-KEUZLBQS.js.map +1 -0
- package/dist/{chunk-XENRC3YO.js → chunk-LCV673G3.js} +605 -41
- package/dist/chunk-LCV673G3.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-PJKIXVSO.js → chunk-PWUJT5HE.js} +898 -238
- package/dist/chunk-PWUJT5HE.js.map +1 -0
- package/dist/{chunk-WSA5QPTA.js → chunk-S4JVAHBR.js} +2 -2
- package/dist/{chunk-UJQ7PID5.js → chunk-WBBMEAHU.js} +78 -3
- package/dist/chunk-WBBMEAHU.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-J4Z2PMUQ.js +9 -0
- package/dist/{doctor-command-WB3O2H64.js → doctor-command-WEHFANT7.js} +3 -3
- package/dist/{filters-Q3ALKWZ5.js → filters-MQG2RMPX.js} +4 -2
- package/dist/flow-C2JQ7gUu.d.ts +95 -0
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/index.d.ts +214 -20
- package/dist/index.js +173 -6
- 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-5NINZVOK.js} +21 -1
- package/dist/screenshot-compare-5NINZVOK.js.map +1 -0
- package/dist/{server-QWJJB3WG.js → server-3MGZNK67.js} +2 -2
- package/dist/{server-PRM7BVVD.js → server-OANRDAHN.js} +5 -5
- package/dist/{session-Ddem-Q5n.d.ts → session-Daq0mE_a.d.ts} +22 -1
- package/dist/{session-2E6OK6BH.js → session-Q3QYHT4Q.js} +4 -4
- package/dist/{studio-command-O3NN5BCG.js → studio-command-RJYLJT4I.js} +2 -2
- package/dist/{test-command-FYOZ6QAE.js → test-command-ALH5ZQY5.js} +23 -9
- package/dist/test-command-ALH5ZQY5.js.map +1 -0
- package/dist/{validator-HZ2A3NEI.js → validator-BLOLIHUY.js} +3 -3
- package/package.json +2 -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/screenshot-compare-3QRHHSFZ.js.map +0 -1
- package/dist/test-command-FYOZ6QAE.js.map +0 -1
- /package/dist/{chunk-WSA5QPTA.js.map → chunk-S4JVAHBR.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-J4Z2PMUQ.js.map} +0 -0
- /package/dist/{doctor-command-WB3O2H64.js.map → doctor-command-WEHFANT7.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-QWJJB3WG.js.map → server-3MGZNK67.js.map} +0 -0
- /package/dist/{server-PRM7BVVD.js.map → server-OANRDAHN.js.map} +0 -0
- /package/dist/{session-2E6OK6BH.js.map → session-Q3QYHT4Q.js.map} +0 -0
- /package/dist/{studio-command-O3NN5BCG.js.map → studio-command-RJYLJT4I.js.map} +0 -0
- /package/dist/{validator-HZ2A3NEI.js.map → validator-BLOLIHUY.js.map} +0 -0
|
@@ -2,303 +2,179 @@
|
|
|
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_input_text` / `spana_press_key` | Execute verified pointer/keyboard actions (2–4 ms on web) |
|
|
20
|
+
| `spana_assert_visible` / `spana_assert_text` | Run real auto-waiting assertions (~1 ms on web) |
|
|
21
|
+
| `spana_diagnostics` | Fetch browser console logs & uncaught JS errors (~0.8 ms) |
|
|
22
|
+
| `spana_screenshot` | Capture PNG screenshot when visual inspection is needed |
|
|
23
|
+
| `spana_export_flow` | Export the verified action trace as a deterministic `.flow.ts` file |
|
|
24
|
+
| `spana_run_flow` / `spana_session_stop` | Execute existing `.flow.ts` files and cleanly tear down |
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
---
|
|
26
27
|
|
|
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
|
|
28
|
+
## CLI Discovery & Execution Loop
|
|
123
29
|
|
|
124
30
|
```bash
|
|
125
|
-
|
|
126
|
-
spana
|
|
127
|
-
```
|
|
31
|
+
# 1. Check environment readiness (web, Android/iOS WebView, WDA/UA2, Electron, Electrobun)
|
|
32
|
+
spana doctor --json
|
|
128
33
|
|
|
129
|
-
|
|
34
|
+
# 2. Discover interactable elements with suggested selectors
|
|
35
|
+
spana selectors --platform web
|
|
36
|
+
spana selectors --platform android
|
|
37
|
+
spana selectors --platform ios
|
|
38
|
+
spana hierarchy --platform web --pretty
|
|
130
39
|
|
|
131
|
-
|
|
40
|
+
# 3. Validate flows without a device/browser
|
|
41
|
+
spana validate-config
|
|
42
|
+
spana validate flows/
|
|
132
43
|
|
|
133
|
-
|
|
134
|
-
spana test --platform web --reporter json
|
|
44
|
+
# 4. Run tests (fast parallel + structured output)
|
|
135
45
|
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
|
|
46
|
+
spana test --platform web --parallel --workers 4
|
|
47
|
+
spana test --changed-since origin/main --reporter console,github
|
|
48
|
+
spana test --last-failed
|
|
49
|
+
spana test --strict-cache # 0-LLM verified replay cache in CI
|
|
144
50
|
|
|
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
|
|
51
|
+
# 5. Manage persistent warm daemons (Chromium / WDA / UiAutomator2)
|
|
52
|
+
spana daemon status
|
|
53
|
+
spana daemon stop
|
|
151
54
|
```
|
|
152
55
|
|
|
153
|
-
|
|
56
|
+
---
|
|
154
57
|
|
|
155
|
-
##
|
|
58
|
+
## Writing Flows
|
|
156
59
|
|
|
157
|
-
###
|
|
60
|
+
### Standard `.flow.ts`
|
|
158
61
|
|
|
159
62
|
```ts
|
|
63
|
+
import { flow, systemUI } from "spana-test";
|
|
64
|
+
|
|
160
65
|
export default flow(
|
|
161
|
-
"
|
|
162
|
-
{
|
|
66
|
+
"SSO sign-in across WebView and native sheet",
|
|
67
|
+
{ tags: ["smoke", "auth"], platforms: ["web", "android", "ios"], timeout: 30_000 },
|
|
163
68
|
async ({ app, expect, platform }) => {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
69
|
+
await app.tap({ testID: "sign-in" }); // ~1 ms DOM lookup -> real native touch
|
|
70
|
+
if (platform !== "web") {
|
|
71
|
+
await app.tap(systemUI({ text: "Continue" })); // SFSafariViewController / Chrome Custom Tabs
|
|
72
|
+
}
|
|
73
|
+
await expect({ testID: "profile-id" }).toBeVisible();
|
|
167
74
|
},
|
|
168
75
|
);
|
|
169
76
|
```
|
|
170
77
|
|
|
171
|
-
###
|
|
78
|
+
### Composable Lazy Fixtures & Named Setups
|
|
172
79
|
|
|
173
80
|
```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
|
-
```
|
|
81
|
+
import { createFlowWithFixtures, defineSetup } from "spana-test";
|
|
189
82
|
|
|
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
|
-
```
|
|
83
|
+
const adminSetup = defineSetup("admin", {
|
|
84
|
+
storage: { localStorage: { auth_token: "test-admin-jwt" } },
|
|
85
|
+
});
|
|
203
86
|
|
|
204
|
-
|
|
87
|
+
const testFlow = createFlowWithFixtures({
|
|
88
|
+
setups: { admin: adminSetup },
|
|
89
|
+
fixtures: {
|
|
90
|
+
seededOrder: async ({ app }, use) => {
|
|
91
|
+
const orderId = "ord_123";
|
|
92
|
+
await use(orderId);
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
});
|
|
205
96
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
"
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
97
|
+
export default testFlow(
|
|
98
|
+
"admin inspects order",
|
|
99
|
+
{ setup: "admin" },
|
|
100
|
+
async ({ app, expect, seededOrder }) => {
|
|
101
|
+
await app.openLink(`/orders/${seededOrder}`);
|
|
102
|
+
await expect({ testID: "order-status" }).toContainText("Paid");
|
|
212
103
|
},
|
|
213
104
|
);
|
|
214
105
|
```
|
|
215
106
|
|
|
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
|
|
107
|
+
---
|
|
226
108
|
|
|
227
|
-
|
|
228
|
-
- `testID` maps to `resource-id`.
|
|
229
|
-
- `app.back()` triggers the system back button.
|
|
230
|
-
- Emulators and physical devices supported.
|
|
109
|
+
## Selector Priority & Dual-Channel Rules
|
|
231
110
|
|
|
232
|
-
|
|
111
|
+
1. **`{ testID: "..." }`** (preferred) — maps to `data-testid` / `testID` (Web, Shadow DOM, same-origin `<iframe>`, Capacitor WebView, Electron, Electrobun), `resource-id` (Android), and `accessibilityIdentifier` (iOS).
|
|
112
|
+
2. **`systemUI({ text: "..." })` / `systemUI({ accessibilityLabel: "..." })`** — routes straight to native OS UI (permission sheets, OAuth `SFSafariViewController`, Chrome Custom Tabs) and skips DOM channels.
|
|
113
|
+
3. **`{ accessibilityLabel: "..." }`** — OS accessibility label / `aria-label`.
|
|
114
|
+
4. **`{ text: "..." }`** — visible text match.
|
|
115
|
+
5. **Relative selectors:** `{ selector: { text: "Edit" }, below: { testID: "user-row-1" } }` (`below`, `above`, `leftOf`, `rightOf`, `childOf`).
|
|
116
|
+
6. **`{ point: { x, y } }`** — last resort only.
|
|
233
117
|
|
|
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.
|
|
118
|
+
### Common `app` & `expect` APIs
|
|
239
119
|
|
|
240
|
-
|
|
120
|
+
- **Actions:** `app.tap()`, `app.doubleTap()`, `app.longPress()`, `app.inputText()`, `app.pressKey()`, `app.dismissKeyboard()`, `app.scrollUntilVisible()`, `app.backUntilVisible()`, `app.openLink()`, `app.takeScreenshot()`, `app.evaluate()`
|
|
121
|
+
- **Web helpers:** `app.mockNetwork()`, `app.blockNetwork()`, `app.setNetworkConditions()`, `app.saveAuthState()`, `app.loadAuthState()`, `app.getConsoleLogs()`, `app.getJSErrors()`, `app.openStory()`
|
|
122
|
+
- **Assertions (auto-waiting with MutationObserver reactive waits on web):** `toBeVisible()`, `toBeHidden()`, `toHaveText()`, `toContainText()`, `toMatchText()`, `toHaveValue()`, `toBeEnabled()`, `toBeDisabled()`, `toHaveAttribute()`, `toMatchScreenshot({ mode: "layout-tolerant" })`, `toPassAccessibilityAudit()`
|
|
241
123
|
|
|
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>` |
|
|
124
|
+
---
|
|
250
125
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
## Config reference
|
|
254
|
-
|
|
255
|
-
`spana.config.ts` at project root:
|
|
126
|
+
## Fast Configuration & CI Filters (`spana.config.ts`)
|
|
256
127
|
|
|
257
128
|
```ts
|
|
258
|
-
import {
|
|
129
|
+
import {
|
|
130
|
+
defineConfig,
|
|
131
|
+
decisionFilter,
|
|
132
|
+
createLogprobDecisionJudge,
|
|
133
|
+
pathRuleFilter,
|
|
134
|
+
} from "spana-test";
|
|
259
135
|
|
|
260
136
|
export default defineConfig({
|
|
261
137
|
apps: {
|
|
262
138
|
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
|
|
139
|
+
android: { packageName: "com.example.app", appPath: "./builds/app.apk" },
|
|
140
|
+
ios: { bundleId: "com.example.app", appPath: "./builds/MyApp.app" },
|
|
274
141
|
},
|
|
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 */
|
|
142
|
+
execution: {
|
|
143
|
+
web: {
|
|
144
|
+
browser: "chromium", // or engine: "cdp" | "lightpanda" with cdpUrl, or wsEndpoint for BrowserStack Automate Web
|
|
145
|
+
headless: true,
|
|
146
|
+
warmBrowser: true,
|
|
147
|
+
instantAnimations: true,
|
|
148
|
+
blockResources: ["image", "font", "media"],
|
|
294
149
|
},
|
|
295
150
|
},
|
|
151
|
+
defaults: {
|
|
152
|
+
waitTimeout: 5000,
|
|
153
|
+
failFastWhenIdle: false, // set true on web to fail missing selectors once page is idle
|
|
154
|
+
},
|
|
155
|
+
filters: [
|
|
156
|
+
pathRuleFilter({
|
|
157
|
+
rules: [{ matchFlow: { tag: "billing" }, watchPaths: ["src/billing/"] }],
|
|
158
|
+
}),
|
|
159
|
+
decisionFilter({
|
|
160
|
+
alwaysRunTags: ["smoke"],
|
|
161
|
+
judge: createLogprobDecisionJudge({
|
|
162
|
+
provider: "openai",
|
|
163
|
+
baseUrl: "http://127.0.0.1:8000/v1",
|
|
164
|
+
model: "typesafe-ai/jev",
|
|
165
|
+
}),
|
|
166
|
+
}),
|
|
167
|
+
],
|
|
168
|
+
reporters: ["console", "html"],
|
|
296
169
|
});
|
|
297
170
|
```
|
|
298
171
|
|
|
299
|
-
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Failure Investigation Checklist
|
|
175
|
+
|
|
176
|
+
When a flow fails, inspect `.spana/artifacts/` (or `spana-output/`):
|
|
300
177
|
|
|
301
|
-
- `
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
- `reporters`: use `["json"]` for machine-readable output
|
|
178
|
+
1. Read `failure-bundle.json` — contains the failed step, attempted selector, nearby selector alternatives, inline `consoleLogs` & `jsErrors`, screenshot path, and exact repro command.
|
|
179
|
+
2. Prefer fixing selectors to `{ testID }` over adding sleeps (Spana already uses `MutationObserver` reactive waits + adaptive polling).
|
|
180
|
+
3. Always run `spana validate` before `spana test` after editing flows.
|
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-Daq0mE_a.js';
|
|
2
|
+
import '../app-DcLXtpv4.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-WBBMEAHU.js";
|
|
9
9
|
import "../chunk-HCG4CJKR.js";
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-PWUJT5HE.js";
|
|
11
|
+
import "../chunk-LCV673G3.js";
|
|
12
12
|
import "../chunk-HYSTRWYN.js";
|
|
13
13
|
import "../chunk-DTNK54C2.js";
|
|
14
14
|
import "../chunk-S5JNNDXS.js";
|