spana-test 0.1.0 → 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.
- package/.agents/skills/spana-testing/SKILL.md +4 -1
- package/README.md +277 -86
- package/dist/agent/index.d.ts +34 -5
- package/dist/agent/index.js +14 -10
- package/dist/{chunk-RK4Z6C7M.js → chunk-3YR4GUGE.js} +3 -2
- package/dist/chunk-3YR4GUGE.js.map +1 -0
- package/dist/{chunk-WIJYK22K.js → chunk-AEKDFFPJ.js} +2 -2
- package/dist/chunk-BF37W5EG.js +125 -0
- package/dist/chunk-BF37W5EG.js.map +1 -0
- package/dist/chunk-EXLUY7KT.js +21 -0
- package/dist/chunk-EXLUY7KT.js.map +1 -0
- package/dist/chunk-FNDOEMOL.js +62 -0
- package/dist/chunk-FNDOEMOL.js.map +1 -0
- package/dist/chunk-HWFDXIXR.js +183 -0
- package/dist/chunk-HWFDXIXR.js.map +1 -0
- package/dist/chunk-IJIASIX5.js +314 -0
- package/dist/chunk-IJIASIX5.js.map +1 -0
- package/dist/chunk-KJPHH2TW.js +168 -0
- package/dist/chunk-KJPHH2TW.js.map +1 -0
- package/dist/{chunk-RJ5VPHVX.js → chunk-L7MFJF46.js} +16 -6
- package/dist/chunk-L7MFJF46.js.map +1 -0
- package/dist/{chunk-5XO6S7AI.js → chunk-MRH7SK52.js} +4 -4
- package/dist/chunk-MRH7SK52.js.map +1 -0
- package/dist/{chunk-53MUJUJY.js → chunk-P7JQRLP4.js} +5 -4
- package/dist/{chunk-53MUJUJY.js.map → chunk-P7JQRLP4.js.map} +1 -1
- package/dist/chunk-S2XNAKSO.js +1087 -0
- package/dist/chunk-S2XNAKSO.js.map +1 -0
- package/dist/{chunk-VDWWIVM6.js → chunk-S4R4OR7T.js} +108 -53
- package/dist/chunk-S4R4OR7T.js.map +1 -0
- package/dist/{chunk-V62HFH6E.js → chunk-SFBRFB2N.js} +14 -6
- package/dist/chunk-SFBRFB2N.js.map +1 -0
- package/dist/{chunk-PWEOJKUF.js → chunk-VNYF5BHX.js} +28 -7
- package/dist/chunk-VNYF5BHX.js.map +1 -0
- package/dist/chunk-WBU34APM.js +38 -0
- package/dist/chunk-WBU34APM.js.map +1 -0
- package/dist/{chunk-CKJQX73M.js → chunk-WQ4GXUUE.js} +921 -352
- package/dist/chunk-WQ4GXUUE.js.map +1 -0
- package/dist/chunk-YBZCOQXJ.js +311 -0
- package/dist/chunk-YBZCOQXJ.js.map +1 -0
- package/dist/cli.js +316 -40
- package/dist/cli.js.map +1 -1
- package/dist/{compiler-G75RIIYS.js → compiler-74VGKZO6.js} +2 -2
- package/dist/{compiler-G75RIIYS.js.map → compiler-74VGKZO6.js.map} +1 -1
- package/dist/config-loader-BJJ3IJJ7.js +9 -0
- package/dist/{console-FV4RJPO4.js → console-XWKUTP3D.js} +39 -7
- package/dist/console-XWKUTP3D.js.map +1 -0
- package/dist/{config-Dg9O0rcQ.d.ts → coordinator-BbUjvvnX.d.ts} +165 -1
- package/dist/{discover-RWBKI5IB.js → discover-KZKXHZZA.js} +3 -3
- package/dist/doctor-command-T2UX5RV5.js +732 -0
- package/dist/doctor-command-T2UX5RV5.js.map +1 -0
- package/dist/{element-CGteXiXB.d.ts → element-DZ0HyJ3C.d.ts} +2 -0
- package/dist/{flow-D-_tlLpp.d.ts → flow-BUC9Mf8W.d.ts} +38 -9
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/{html-JP2HBIJQ.js → html-GE6Q4DCG.js} +23 -3
- package/dist/html-GE6Q4DCG.js.map +1 -0
- package/dist/index.d.ts +171 -3
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/{init-command-CELKL2CX.js → init-command-GVMRXIMY.js} +37 -21
- package/dist/init-command-GVMRXIMY.js.map +1 -0
- package/dist/init-flow-command-R76AXF4Z.js +34 -0
- package/dist/init-flow-command-R76AXF4Z.js.map +1 -0
- package/dist/{installer-R6NX7BYQ.js → installer-YZJ4DV3F.js} +4 -2
- package/dist/{ios-ZZU6DHH7.js → ios-ZW6XVNLG.js} +4 -2
- package/dist/json-KS67BZYU.js +39 -0
- package/dist/json-KS67BZYU.js.map +1 -0
- package/dist/{junit-UDY5JG22.js → junit-HLC62MK6.js} +2 -2
- package/dist/junit-HLC62MK6.js.map +1 -0
- package/dist/provider-A57C3MU6.js +12 -0
- package/dist/{redact-IDA3C4UH.js → redact-U72BUBBR.js} +2 -2
- package/dist/{redact-IDA3C4UH.js.map → redact-U72BUBBR.js.map} +1 -1
- package/dist/{runner-QEF6PJOE.js → runner-UXNHVVGG.js} +2 -2
- package/dist/{server-MMK7PZIH.js → server-W7OA3DDN.js} +49 -24
- package/dist/server-W7OA3DDN.js.map +1 -0
- package/dist/session-TMNOKYLG.js +17 -0
- package/dist/{studio-command-CDVPREMG.js → studio-command-6VHTHDUK.js} +2 -2
- package/dist/{test-command-SB5KYPQI.js → test-command-AHMOZLV4.js} +1280 -357
- package/dist/test-command-AHMOZLV4.js.map +1 -0
- package/dist/validator-35624P7S.js +20 -0
- package/package.json +1 -1
- package/studio-dist/assets/index-DC6DIXfl.js +188 -0
- package/studio-dist/assets/index-DDKsnBwD.css +1 -0
- package/studio-dist/index.html +2 -2
- package/dist/chunk-5XO6S7AI.js.map +0 -1
- package/dist/chunk-BZRLA4Z3.js +0 -82
- package/dist/chunk-BZRLA4Z3.js.map +0 -1
- package/dist/chunk-CKJQX73M.js.map +0 -1
- package/dist/chunk-PANFRTIU.js +0 -310
- package/dist/chunk-PANFRTIU.js.map +0 -1
- package/dist/chunk-PWEOJKUF.js.map +0 -1
- package/dist/chunk-RJ5VPHVX.js.map +0 -1
- package/dist/chunk-RK4Z6C7M.js.map +0 -1
- package/dist/chunk-U564GCO2.js +0 -259
- package/dist/chunk-U564GCO2.js.map +0 -1
- package/dist/chunk-V62HFH6E.js.map +0 -1
- package/dist/chunk-VDWWIVM6.js.map +0 -1
- package/dist/config-loader-JJ5RPP53.js +0 -9
- package/dist/console-FV4RJPO4.js.map +0 -1
- package/dist/html-JP2HBIJQ.js.map +0 -1
- package/dist/init-command-CELKL2CX.js.map +0 -1
- package/dist/json-JMRPUVY2.js +0 -20
- package/dist/json-JMRPUVY2.js.map +0 -1
- package/dist/junit-UDY5JG22.js.map +0 -1
- package/dist/provider-CUWPULGC.js +0 -10
- package/dist/server-MMK7PZIH.js.map +0 -1
- package/dist/session-FBJABNXL.js +0 -16
- package/dist/test-command-SB5KYPQI.js.map +0 -1
- package/dist/validator-CFQ55NUQ.js +0 -13
- package/studio-dist/assets/index-CPdpC9i-.css +0 -1
- package/studio-dist/assets/index-L1Wd0vop.js +0 -183
- /package/dist/{chunk-WIJYK22K.js.map → chunk-AEKDFFPJ.js.map} +0 -0
- /package/dist/{config-loader-JJ5RPP53.js.map → config-loader-BJJ3IJJ7.js.map} +0 -0
- /package/dist/{discover-RWBKI5IB.js.map → discover-KZKXHZZA.js.map} +0 -0
- /package/dist/{installer-R6NX7BYQ.js.map → installer-YZJ4DV3F.js.map} +0 -0
- /package/dist/{ios-ZZU6DHH7.js.map → ios-ZW6XVNLG.js.map} +0 -0
- /package/dist/{provider-CUWPULGC.js.map → provider-A57C3MU6.js.map} +0 -0
- /package/dist/{runner-QEF6PJOE.js.map → runner-UXNHVVGG.js.map} +0 -0
- /package/dist/{session-FBJABNXL.js.map → session-TMNOKYLG.js.map} +0 -0
- /package/dist/{studio-command-CDVPREMG.js.map → studio-command-6VHTHDUK.js.map} +0 -0
- /package/dist/{validator-CFQ55NUQ.js.map → validator-35624P7S.js.map} +0 -0
|
@@ -66,13 +66,16 @@ export default flow(
|
|
|
66
66
|
| `app.inputText(text)` | Type text into focused element |
|
|
67
67
|
| `app.pressKey(key)` | Press a keyboard key |
|
|
68
68
|
| `app.hideKeyboard()` | Dismiss keyboard |
|
|
69
|
+
| `app.dismissKeyboard(opts?)` | Platform-aware keyboard dismissal |
|
|
69
70
|
| `app.swipe(direction, opts?)` | Swipe: "up"/"down"/"left"/"right" |
|
|
70
71
|
| `app.scroll(direction)` | Scroll (slower swipe) |
|
|
72
|
+
| `app.scrollUntilVisible(sel)` | Scroll until target is visible |
|
|
71
73
|
| `app.launch(opts?)` | Launch/relaunch app |
|
|
72
74
|
| `app.stop()` / `app.kill()` | Stop or force-kill app |
|
|
73
75
|
| `app.clearState()` | Clear app data |
|
|
74
76
|
| `app.openLink(url)` | Open deep link or URL |
|
|
75
77
|
| `app.back()` | Navigate back |
|
|
78
|
+
| `app.backUntilVisible(sel)` | Back until target is visible |
|
|
76
79
|
| `app.takeScreenshot(name?)` | Capture screenshot |
|
|
77
80
|
| `app.evaluate(fn, ...args)` | Run JS in web context |
|
|
78
81
|
|
|
@@ -172,7 +175,7 @@ await app.tap({ testID: "email-input" });
|
|
|
172
175
|
await app.inputText("user@example.com");
|
|
173
176
|
await app.tap({ testID: "password-input" });
|
|
174
177
|
await app.inputText("secret123");
|
|
175
|
-
await app.
|
|
178
|
+
await app.dismissKeyboard();
|
|
176
179
|
await app.tap({ testID: "submit-btn" });
|
|
177
180
|
await expect({ testID: "dashboard" }).toBeVisible();
|
|
178
181
|
```
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# spana
|
|
2
2
|
|
|
3
|
-
TypeScript-native E2E testing for React Native + Web
|
|
3
|
+
TypeScript-native E2E testing for React Native + Web.
|
|
4
4
|
|
|
5
5
|
[Documentation](https://wezter96.github.io/spana/) | [GitHub](https://github.com/wezter96/spana) | [npm](https://www.npmjs.com/package/spana-test) | [E2E Test Report](https://htmlpreview.github.io/?https://github.com/wezter96/spana/blob/main/docs/e2e-report.html)
|
|
6
6
|
|
|
@@ -8,13 +8,16 @@ TypeScript-native E2E testing for React Native + Web
|
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
11
|
-
- Pure TypeScript
|
|
12
|
-
- Cross-platform
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
11
|
+
- Pure TypeScript flows, plus optional Gherkin / BDD `.feature` support
|
|
12
|
+
- Cross-platform execution across web, Android, and iOS from the same suite
|
|
13
|
+
- Local web via Playwright, local Android via UiAutomator2, local iOS via WebDriverAgent, plus Appium cloud mode
|
|
14
|
+
- Smart waits, retries, relative selectors, and per-flow stability defaults
|
|
15
|
+
- Reporters: console, JSON, JUnit XML, HTML, and Allure
|
|
16
|
+
- Artifacts on failure or success: screenshots, UI hierarchy dumps, per-step capture, and web HAR / diagnostics
|
|
17
|
+
- App auto-install with `appPath`, iOS device signing, and BrowserStack / Sauce helper services
|
|
18
|
+
- CLI tooling for teams and agents: `validate`, `validate-config`, `init`, `studio`, `selectors`, `hierarchy`, and `devices`
|
|
19
|
+
- Execution controls for targeted and CI runs: `--device`, `--shard`, `--bail`, `--debug-on-failure`
|
|
20
|
+
- Browser helpers for network/auth state, uploads/downloads, tabs/HAR diagnostics, plus WebView / hybrid context APIs where the driver supports them
|
|
18
21
|
|
|
19
22
|
---
|
|
20
23
|
|
|
@@ -34,23 +37,36 @@ import { defineConfig } from "spana-test";
|
|
|
34
37
|
export default defineConfig({
|
|
35
38
|
apps: {
|
|
36
39
|
web: { url: "http://localhost:3000" },
|
|
37
|
-
android: {
|
|
38
|
-
|
|
40
|
+
android: {
|
|
41
|
+
packageName: "com.example.app",
|
|
42
|
+
appPath: "./builds/app.apk",
|
|
43
|
+
},
|
|
44
|
+
ios: {
|
|
45
|
+
bundleId: "com.example.app",
|
|
46
|
+
appPath: "./builds/MyApp.app",
|
|
47
|
+
},
|
|
39
48
|
},
|
|
40
49
|
platforms: ["web", "android"],
|
|
50
|
+
reporters: ["console", "html"],
|
|
51
|
+
artifacts: {
|
|
52
|
+
outputDir: ".spana/artifacts",
|
|
53
|
+
captureOnFailure: true,
|
|
54
|
+
},
|
|
41
55
|
});
|
|
42
56
|
```
|
|
43
57
|
|
|
44
|
-
Create `flows/login.ts`:
|
|
58
|
+
Create `flows/login.flow.ts`:
|
|
45
59
|
|
|
46
60
|
```ts
|
|
47
61
|
import { flow } from "spana-test";
|
|
48
62
|
|
|
49
63
|
export default flow("user can log in", async ({ app, expect }) => {
|
|
50
64
|
await app.tap({ testID: "email-input" });
|
|
51
|
-
await app.
|
|
65
|
+
await app.inputText("user@example.com");
|
|
66
|
+
await app.dismissKeyboard();
|
|
52
67
|
await app.tap({ testID: "password-input" });
|
|
53
|
-
await app.
|
|
68
|
+
await app.inputText("secret");
|
|
69
|
+
await app.dismissKeyboard();
|
|
54
70
|
await app.tap({ testID: "login-button" });
|
|
55
71
|
await expect({ testID: "home-screen" }).toBeVisible();
|
|
56
72
|
});
|
|
@@ -59,11 +75,27 @@ export default flow("user can log in", async ({ app, expect }) => {
|
|
|
59
75
|
Run:
|
|
60
76
|
|
|
61
77
|
```bash
|
|
78
|
+
spana validate-config
|
|
79
|
+
spana validate ./flows
|
|
62
80
|
spana test
|
|
63
81
|
```
|
|
64
82
|
|
|
65
83
|
---
|
|
66
84
|
|
|
85
|
+
## Capability Matrix
|
|
86
|
+
|
|
87
|
+
| Capability | Web | Local Android / iOS | Appium cloud |
|
|
88
|
+
| ---------------------------------------------------- | --- | -------------------------------- | ------------------------------------------ |
|
|
89
|
+
| TypeScript `.flow.ts` suites | Yes | Yes | Yes |
|
|
90
|
+
| Gherkin `.feature` suites | Yes | Yes | Yes |
|
|
91
|
+
| Smart waits, retries, relative selectors | Yes | Yes | Yes |
|
|
92
|
+
| HTML / JUnit / Allure reports and artifacts | Yes | Yes | Yes |
|
|
93
|
+
| App install / app reference handling | n/a | Yes, via `appPath` | Yes, via capabilities and provider helpers |
|
|
94
|
+
| Browser helpers (`mockNetwork`, cookies, downloads, tabs, HAR`) | Yes | No | No |
|
|
95
|
+
| WebView context APIs | n/a | Android yes, iOS via Appium mode | Yes |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
67
99
|
## Writing Flows
|
|
68
100
|
|
|
69
101
|
### Basic API
|
|
@@ -71,74 +103,96 @@ spana test
|
|
|
71
103
|
```ts
|
|
72
104
|
import { flow } from "spana-test";
|
|
73
105
|
|
|
74
|
-
export default flow("flow name", async ({ app, expect, platform }) => {
|
|
75
|
-
// tap, type, scroll
|
|
76
|
-
await app.tap({ text: "Sign In" });
|
|
77
|
-
await app.typeText("hello");
|
|
78
|
-
await app.scroll({ direction: "down" });
|
|
79
|
-
|
|
80
|
-
// assertions
|
|
81
|
-
await expect({ testID: "welcome" }).toBeVisible();
|
|
82
|
-
await expect({ text: "Welcome" }).toBeVisible();
|
|
83
|
-
|
|
84
|
-
// platform branching
|
|
85
|
-
if (platform === "web") {
|
|
86
|
-
await app.tap({ testID: "web-only-button" });
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### With config
|
|
92
|
-
|
|
93
|
-
```ts
|
|
94
106
|
export default flow(
|
|
95
107
|
"checkout flow",
|
|
96
|
-
{
|
|
108
|
+
{
|
|
109
|
+
tags: ["smoke", "payments"],
|
|
110
|
+
platforms: ["android", "ios"],
|
|
111
|
+
timeout: 60_000,
|
|
112
|
+
defaults: {
|
|
113
|
+
waitForIdleTimeout: 250,
|
|
114
|
+
typingDelay: 20,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
97
117
|
async ({ app, expect }) => {
|
|
98
|
-
|
|
118
|
+
await app.tap({ text: "Sign In" });
|
|
119
|
+
await app.inputText("hello@example.com");
|
|
120
|
+
await app.dismissKeyboard();
|
|
121
|
+
|
|
122
|
+
await app.scrollUntilVisible({ testID: "order-summary" });
|
|
123
|
+
await app.doubleTap({ testID: "promo-card" });
|
|
124
|
+
await app.longPress({ testID: "options-trigger" });
|
|
125
|
+
await app.scroll("down");
|
|
126
|
+
|
|
127
|
+
await expect({ testID: "welcome" }).toBeVisible();
|
|
128
|
+
await expect({ text: "Welcome" }).toBeVisible();
|
|
99
129
|
},
|
|
100
130
|
);
|
|
101
131
|
```
|
|
102
132
|
|
|
133
|
+
Use `scrollUntilVisible()` for off-screen targets instead of hand-written scroll loops. Use `dismissKeyboard()` for a platform-aware keyboard close path, and `backUntilVisible()` when you want system back navigation to stop on a known screen. Tap-like actions also prefer the nearest actionable container for nested label-inside-button layouts.
|
|
134
|
+
|
|
103
135
|
### FlowConfig options
|
|
104
136
|
|
|
105
|
-
| Option | Type
|
|
106
|
-
| ------------ |
|
|
107
|
-
| `tags` | `string[]`
|
|
108
|
-
| `platforms` | `Platform[]`
|
|
109
|
-
| `timeout` | `number`
|
|
110
|
-
| `autoLaunch` | `boolean`
|
|
137
|
+
| Option | Type | Default | Description |
|
|
138
|
+
| ------------ | ---------------- | -------------- | -------------------------------------------- |
|
|
139
|
+
| `tags` | `string[]` | - | Tags for `--tag` filtering |
|
|
140
|
+
| `platforms` | `Platform[]` | all | Restrict a flow to specific platforms |
|
|
141
|
+
| `timeout` | `number` | config default | Flow timeout in ms |
|
|
142
|
+
| `autoLaunch` | `boolean` | `true` | Launch app before the flow starts |
|
|
143
|
+
| `when` | `WhenCondition` | - | Conditionally run by platform or env |
|
|
144
|
+
| `artifacts` | `ArtifactConfig` | config default | Per-flow artifact overrides |
|
|
145
|
+
| `defaults` | `FlowDefaults` | config default | Per-flow wait / typing / stability overrides |
|
|
146
|
+
|
|
147
|
+
### BDD parity
|
|
148
|
+
|
|
149
|
+
Spana can compile `.feature` files into the same runtime as `.flow.ts` files. Keep Gherkin scenarios for high-value readable coverage, and use step definitions for reuse:
|
|
150
|
+
|
|
151
|
+
```gherkin
|
|
152
|
+
Feature: Login
|
|
153
|
+
Scenario: Signed-out user logs in
|
|
154
|
+
Given I am on the login screen
|
|
155
|
+
When I type valid credentials
|
|
156
|
+
Then I should see the home screen
|
|
157
|
+
```
|
|
111
158
|
|
|
112
159
|
---
|
|
113
160
|
|
|
114
161
|
## CLI Commands
|
|
115
162
|
|
|
116
|
-
| Command
|
|
117
|
-
|
|
|
118
|
-
| `spana test [path]`
|
|
119
|
-
| `spana hierarchy`
|
|
120
|
-
| `spana selectors`
|
|
121
|
-
| `spana validate [path]`
|
|
122
|
-
| `spana
|
|
123
|
-
| `spana
|
|
163
|
+
| Command | Description |
|
|
164
|
+
| ------------------------------ | ------------------------------------------------- |
|
|
165
|
+
| `spana test [path]` | Run test flows (default: `./flows`) |
|
|
166
|
+
| `spana hierarchy` | Dump full element hierarchy as JSON |
|
|
167
|
+
| `spana selectors` | List actionable elements with suggested selectors |
|
|
168
|
+
| `spana validate [path]` | Validate flow files without a device connection |
|
|
169
|
+
| `spana validate-config [path]` | Validate `spana.config.ts` without running flows |
|
|
170
|
+
| `spana studio` | Launch Spana Studio |
|
|
171
|
+
| `spana init` | Scaffold a new Spana project |
|
|
172
|
+
| `spana devices` | List connected devices across all platforms |
|
|
173
|
+
| `spana version` | Show version |
|
|
124
174
|
|
|
125
175
|
### test options
|
|
126
176
|
|
|
127
177
|
```bash
|
|
128
|
-
spana test flows/login.ts
|
|
129
|
-
spana test --platform android,ios
|
|
130
|
-
spana test --
|
|
131
|
-
spana test --grep "log in"
|
|
132
|
-
spana test --reporter
|
|
133
|
-
spana test --
|
|
134
|
-
spana test --
|
|
178
|
+
spana test flows/login.flow.ts # run a single file
|
|
179
|
+
spana test --platform android,ios # target platforms
|
|
180
|
+
spana test --device emulator-5554 # target a specific local device
|
|
181
|
+
spana test --tag smoke --grep "log in" # filter flows
|
|
182
|
+
spana test --reporter html,allure # choose reporters
|
|
183
|
+
spana test --retries 2 --shard 1/3 --bail 5 # CI-friendly execution
|
|
184
|
+
spana test --debug-on-failure # open REPL on the first failure
|
|
185
|
+
spana test --driver appium --appium-url $BROWSERSTACK_URL --caps ./caps/android.json --platform android
|
|
186
|
+
spana test --config ./spana.config.ts # explicit config path
|
|
135
187
|
```
|
|
136
188
|
|
|
137
|
-
###
|
|
189
|
+
### inspection and debugging
|
|
138
190
|
|
|
139
191
|
```bash
|
|
140
192
|
spana hierarchy --platform android --pretty
|
|
141
193
|
spana selectors --platform ios
|
|
194
|
+
spana validate-config
|
|
195
|
+
spana studio --no-open
|
|
142
196
|
```
|
|
143
197
|
|
|
144
198
|
---
|
|
@@ -151,8 +205,15 @@ import { defineConfig } from "spana-test";
|
|
|
151
205
|
export default defineConfig({
|
|
152
206
|
apps: {
|
|
153
207
|
web: { url: "http://localhost:3000" },
|
|
154
|
-
android: {
|
|
155
|
-
|
|
208
|
+
android: {
|
|
209
|
+
packageName: "com.example.app",
|
|
210
|
+
appPath: "./builds/app.apk",
|
|
211
|
+
},
|
|
212
|
+
ios: {
|
|
213
|
+
bundleId: "com.example.app",
|
|
214
|
+
appPath: "./builds/MyApp.app",
|
|
215
|
+
signing: { teamId: "ABCDE12345" },
|
|
216
|
+
},
|
|
156
217
|
},
|
|
157
218
|
execution: {
|
|
158
219
|
web: {
|
|
@@ -160,20 +221,37 @@ export default defineConfig({
|
|
|
160
221
|
headless: true,
|
|
161
222
|
storageState: "./auth/web-user.json",
|
|
162
223
|
},
|
|
224
|
+
appium: {
|
|
225
|
+
serverUrl: process.env.BROWSERSTACK_URL,
|
|
226
|
+
capabilitiesFile: "./caps/browserstack-android.json",
|
|
227
|
+
reportToProvider: true,
|
|
228
|
+
browserstack: {
|
|
229
|
+
local: { enabled: true },
|
|
230
|
+
},
|
|
231
|
+
},
|
|
163
232
|
},
|
|
164
233
|
platforms: ["web", "android", "ios"],
|
|
165
234
|
flowDir: "./flows",
|
|
166
|
-
reporters: ["console", "json", "html"],
|
|
235
|
+
reporters: ["console", "json", "html", "allure"],
|
|
167
236
|
defaults: {
|
|
168
|
-
waitTimeout: 5000,
|
|
169
|
-
pollInterval: 200,
|
|
170
|
-
settleTimeout: 300,
|
|
171
|
-
retries: 2,
|
|
237
|
+
waitTimeout: 5000,
|
|
238
|
+
pollInterval: 200,
|
|
239
|
+
settleTimeout: 300,
|
|
240
|
+
retries: 2,
|
|
241
|
+
waitForIdleTimeout: 250,
|
|
242
|
+
typingDelay: 20,
|
|
243
|
+
initialPollInterval: 50,
|
|
244
|
+
hierarchyCacheTtl: 100,
|
|
245
|
+
retryDelay: 0,
|
|
246
|
+
},
|
|
247
|
+
launchOptions: {
|
|
248
|
+
clearState: false,
|
|
172
249
|
},
|
|
173
250
|
artifacts: {
|
|
174
251
|
outputDir: ".spana/artifacts",
|
|
175
|
-
captureOnFailure: true,
|
|
252
|
+
captureOnFailure: true,
|
|
176
253
|
captureOnSuccess: false,
|
|
254
|
+
captureSteps: false,
|
|
177
255
|
screenshot: true,
|
|
178
256
|
uiHierarchy: true,
|
|
179
257
|
},
|
|
@@ -194,11 +272,13 @@ export default defineConfig({
|
|
|
194
272
|
});
|
|
195
273
|
```
|
|
196
274
|
|
|
197
|
-
`
|
|
275
|
+
`appPath` lets Spana install the app automatically for local Android and iOS runs. `execution.appium.browserstack` and `execution.appium.saucelabs` can also manage uploaded app references plus BrowserStack Local / Sauce Connect lifecycles for cloud runs.
|
|
198
276
|
|
|
199
277
|
### Browser runtime helpers (web)
|
|
200
278
|
|
|
201
279
|
```ts
|
|
280
|
+
import { flow } from "spana-test";
|
|
281
|
+
|
|
202
282
|
export default flow("web dashboard", async ({ app, platform }) => {
|
|
203
283
|
if (platform !== "web") return;
|
|
204
284
|
|
|
@@ -208,35 +288,90 @@ export default flow("web dashboard", async ({ app, platform }) => {
|
|
|
208
288
|
});
|
|
209
289
|
await app.blockNetwork("**/analytics/**");
|
|
210
290
|
await app.setNetworkConditions({ offline: false, latencyMs: 120 });
|
|
291
|
+
await app.evaluate(() => console.info("dashboard hydrated"));
|
|
292
|
+
const download = app.downloadFile("./tmp/dashboard-report.json");
|
|
293
|
+
await app.tap({ testID: "download-report-button" });
|
|
294
|
+
await download;
|
|
295
|
+
await app.uploadFile({ testID: "avatar-upload-input" }, "./fixtures/avatar.png");
|
|
296
|
+
const newTabId = await app.newTab("http://localhost:3000/settings");
|
|
297
|
+
await app.switchToTab(1);
|
|
298
|
+
console.log(await app.getTabIds(), newTabId);
|
|
299
|
+
console.log(await app.getConsoleLogs());
|
|
300
|
+
console.log(await app.getJSErrors());
|
|
301
|
+
console.log(await app.getHAR());
|
|
211
302
|
await app.saveCookies("./tmp/cookies.json");
|
|
212
303
|
});
|
|
213
304
|
```
|
|
214
305
|
|
|
215
|
-
`mockNetwork`, `blockNetwork`, `clearNetworkMocks`, `setNetworkConditions`, `saveCookies`, `loadCookies`, `saveAuthState`, and `
|
|
306
|
+
`mockNetwork`, `blockNetwork`, `clearNetworkMocks`, `setNetworkConditions`, `saveCookies`, `loadCookies`, `saveAuthState`, `loadAuthState`, `downloadFile`, `uploadFile`, `newTab`, `switchToTab`, `closeTab`, `getTabIds`, `getConsoleLogs`, `getJSErrors`, and `getHAR` are web-only helpers backed by local Playwright runs. `downloadFile()` waits for the next browser download and saves it locally; `uploadFile()` supports simple `testID` / `text` / `accessibilityLabel` selectors. Latency and throughput throttling require Chromium. When artifact capture is enabled, web failures also include captured console logs, JavaScript errors, and HAR output in `spana-output/` and the HTML report. Set `execution.web.verboseLogging = true` when you want Playwright runtime events echoed to stdout while debugging.
|
|
307
|
+
|
|
308
|
+
### Hybrid / WebView helpers
|
|
309
|
+
|
|
310
|
+
```ts
|
|
311
|
+
import { flow } from "spana-test";
|
|
312
|
+
|
|
313
|
+
export default flow("hybrid checkout", async ({ app, platform }) => {
|
|
314
|
+
if (platform === "web") return;
|
|
315
|
+
|
|
316
|
+
const contexts = await app.getContexts();
|
|
317
|
+
await app.switchToWebView();
|
|
318
|
+
await app.switchToNativeApp();
|
|
319
|
+
|
|
320
|
+
console.log(contexts);
|
|
321
|
+
});
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Context APIs depend on driver support. Appium mode is the best path for iOS WebView automation.
|
|
216
325
|
|
|
217
326
|
---
|
|
218
327
|
|
|
219
328
|
## Selectors
|
|
220
329
|
|
|
221
|
-
| Selector | Example | Notes
|
|
222
|
-
| -------------------- | --------------------------------- |
|
|
223
|
-
| `testID` | `{ testID: "login-btn" }` | Preferred
|
|
224
|
-
| `text` | `{ text: "Sign In" }` | Visible label text, partial match supported
|
|
225
|
-
| `accessibilityLabel` | `{ accessibilityLabel: "Close" }` | OS accessibility label
|
|
226
|
-
| `point` | `{ point: { x: 100, y: 200 } }` | Absolute coordinate tap, use as last resort
|
|
330
|
+
| Selector | Example | Notes |
|
|
331
|
+
| -------------------- | --------------------------------- | ----------------------------------------------------------------------------------------------------- |
|
|
332
|
+
| `testID` | `{ testID: "login-btn" }` | Preferred - maps to `accessibilityIdentifier` (iOS), `resource-id` (Android), and `data-testid` (web) |
|
|
333
|
+
| `text` | `{ text: "Sign In" }` | Visible label text, partial match supported |
|
|
334
|
+
| `accessibilityLabel` | `{ accessibilityLabel: "Close" }` | OS accessibility label |
|
|
335
|
+
| `point` | `{ point: { x: 100, y: 200 } }` | Absolute coordinate tap, use as a last resort |
|
|
227
336
|
|
|
228
337
|
Selectors can be combined. When multiple fields are set, all must match.
|
|
229
338
|
|
|
339
|
+
### Relative selectors
|
|
340
|
+
|
|
341
|
+
For actions that accept an extended selector, you can locate an element relative to another one:
|
|
342
|
+
|
|
343
|
+
```ts
|
|
344
|
+
await app.tap({
|
|
345
|
+
selector: { testID: "confirm-button" },
|
|
346
|
+
below: { text: "Delete account" },
|
|
347
|
+
});
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Supported relations: `below`, `above`, `leftOf`, `rightOf`, and `childOf`.
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Tooling and Debugging
|
|
355
|
+
|
|
356
|
+
Spana ships a few built-in workflows that are easy to miss from the minimal quick start:
|
|
357
|
+
|
|
358
|
+
- `spana validate-config` catches config issues before a suite starts
|
|
359
|
+
- `spana init` scaffolds a starter project
|
|
360
|
+
- `spana devices` lists local execution targets
|
|
361
|
+
- `spana studio` launches a browser UI for inspection and test runs
|
|
362
|
+
- `--debug-on-failure` drops into an interactive REPL with bound `app` and driver context
|
|
363
|
+
- `--device`, `--shard`, and `--bail` help with targeted local runs and CI fan-out
|
|
364
|
+
|
|
230
365
|
---
|
|
231
366
|
|
|
232
367
|
## Agent Integration
|
|
233
368
|
|
|
234
369
|
`spana` is designed for AI agent workflows:
|
|
235
370
|
|
|
236
|
-
- `spana selectors --platform android` returns JSON with element details and suggested selectors
|
|
237
|
-
- `spana hierarchy --platform web --pretty` dumps the
|
|
238
|
-
- `spana validate` exits non-zero on invalid flows
|
|
239
|
-
- `--reporter json` emits structured JSON events to stdout
|
|
371
|
+
- `spana selectors --platform android` returns JSON with element details and suggested selectors
|
|
372
|
+
- `spana hierarchy --platform web --pretty` dumps the accessibility tree as structured JSON
|
|
373
|
+
- `spana validate` exits non-zero on invalid flows, which works well as a preflight step
|
|
374
|
+
- `--reporter json` emits structured JSON events to stdout for downstream analysis
|
|
240
375
|
|
|
241
376
|
Example agent loop:
|
|
242
377
|
|
|
@@ -245,29 +380,85 @@ Example agent loop:
|
|
|
245
380
|
spana selectors --platform web | jq '.[] | select(.testID != null)'
|
|
246
381
|
|
|
247
382
|
# 2. run a specific flow with JSON output
|
|
248
|
-
spana test flows/login.ts --reporter json 2>&1 | jq '.results'
|
|
383
|
+
spana test flows/login.flow.ts --reporter json 2>&1 | jq '.results'
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## Cloud Testing
|
|
389
|
+
|
|
390
|
+
Spana supports running the same TypeScript flows on cloud device farms via Appium mode.
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
# BrowserStack
|
|
394
|
+
spana test --driver appium --appium-url $BROWSERSTACK_URL --caps ./caps/browserstack-android.json --platform android
|
|
395
|
+
|
|
396
|
+
# Sauce Labs
|
|
397
|
+
spana test --driver appium --appium-url $SAUCE_URL --caps ./caps/saucelabs-android.json --platform android
|
|
249
398
|
```
|
|
250
399
|
|
|
400
|
+
Or configure it in `spana.config.ts`:
|
|
401
|
+
|
|
402
|
+
```ts
|
|
403
|
+
import { defineConfig } from "spana-test";
|
|
404
|
+
|
|
405
|
+
export default defineConfig({
|
|
406
|
+
execution: {
|
|
407
|
+
mode: "appium",
|
|
408
|
+
appium: {
|
|
409
|
+
serverUrl: process.env.BROWSERSTACK_URL,
|
|
410
|
+
capabilitiesFile: "./caps/browserstack-android.json",
|
|
411
|
+
reportToProvider: true,
|
|
412
|
+
browserstack: {
|
|
413
|
+
local: { enabled: true },
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
apps: {
|
|
418
|
+
android: {
|
|
419
|
+
packageName: "com.example.myapp",
|
|
420
|
+
appPath: "./builds/app.apk",
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
Spana ships first-class helper services for **BrowserStack** and **Sauce Labs**:
|
|
427
|
+
|
|
428
|
+
- managed app upload and app reference resolution
|
|
429
|
+
- BrowserStack Local lifecycle management
|
|
430
|
+
- Sauce Connect lifecycle management
|
|
431
|
+
- provider result reporting
|
|
432
|
+
|
|
433
|
+
Generic Appium hubs still work even without provider-specific helpers.
|
|
434
|
+
|
|
435
|
+
Guides:
|
|
436
|
+
|
|
437
|
+
- [BrowserStack setup](https://github.com/wezter96/spana/blob/main/docs/cloud/browserstack.md)
|
|
438
|
+
- [Sauce Labs setup](https://github.com/wezter96/spana/blob/main/docs/cloud/saucelabs.md)
|
|
439
|
+
- [Example capabilities](https://github.com/wezter96/spana/tree/main/examples/caps)
|
|
440
|
+
|
|
251
441
|
---
|
|
252
442
|
|
|
253
443
|
## Architecture
|
|
254
444
|
|
|
255
445
|
spana uses a layered architecture: CLI -> TestRunner -> PlatformOrchestrator -> SmartLayer -> RawDriver.
|
|
256
446
|
|
|
257
|
-
Raw drivers are thin HTTP clients. All selector matching, auto-wait, retry, and element resolution lives in the TypeScript
|
|
447
|
+
Raw drivers are thin HTTP clients. All selector matching, auto-wait, retry, and element resolution lives in the TypeScript smart layer instead of companion binaries.
|
|
258
448
|
|
|
259
|
-
See [ARCHITECTURE.md](
|
|
449
|
+
See [ARCHITECTURE.md](https://github.com/wezter96/spana/blob/main/ARCHITECTURE.md) for details.
|
|
260
450
|
|
|
261
451
|
---
|
|
262
452
|
|
|
263
453
|
## Platforms
|
|
264
454
|
|
|
265
|
-
| Platform | Driver
|
|
266
|
-
| ------------- |
|
|
267
|
-
| Web / RN Web | Playwright (CDP)
|
|
268
|
-
| Android | UiAutomator2 HTTP client
|
|
269
|
-
| iOS Simulator | WebDriverAgent HTTP client
|
|
270
|
-
| iOS Device | Same WDA bundle
|
|
455
|
+
| Platform | Driver | Companion binary |
|
|
456
|
+
| ------------- | --------------------------- | -------------------------------------------------------- |
|
|
457
|
+
| Web / RN Web | Playwright (CDP) | None - Playwright is a dev dependency |
|
|
458
|
+
| Android | UiAutomator2 HTTP client | Appium UiAutomator2 server APK (bundled) |
|
|
459
|
+
| iOS Simulator | WebDriverAgent HTTP client | WDA XCTest bundle (bundled unsigned) |
|
|
460
|
+
| iOS Device | Same WDA bundle | Re-signed with `codesign`; requires `iproxy` |
|
|
461
|
+
| Appium cloud | Appium 2 / 3 compatible hub | BrowserStack, Sauce Labs, or another W3C-compatible grid |
|
|
271
462
|
|
|
272
463
|
---
|
|
273
464
|
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Platform,
|
|
2
|
-
import { E as Element } from '../element-
|
|
1
|
+
import { P as Platform, g as BrowserName, q as RawDriverService, l as Selector, E as ExtendedSelector, S as ScrollUntilVisibleOptions, B as BackUntilVisibleOptions, j as DismissKeyboardOptions, L as LaunchOptions, i as BrowserRouteMatcher, f as BrowserMockResponse, h as BrowserNetworkConditions, c as BrowserConsoleLog, e as BrowserJSError, d as BrowserHAR } from '../coordinator-BbUjvvnX.js';
|
|
2
|
+
import { E as Element } from '../element-DZ0HyJ3C.js';
|
|
3
3
|
import 'effect';
|
|
4
4
|
|
|
5
5
|
type Direction = "up" | "down" | "left" | "right";
|
|
@@ -12,6 +12,7 @@ interface ConnectOptions {
|
|
|
12
12
|
headless?: boolean;
|
|
13
13
|
browser?: BrowserName;
|
|
14
14
|
storageState?: string;
|
|
15
|
+
verboseLogging?: boolean;
|
|
15
16
|
}
|
|
16
17
|
interface SuggestedSelector {
|
|
17
18
|
suggestedSelector: Selector;
|
|
@@ -32,7 +33,9 @@ declare class Session {
|
|
|
32
33
|
readonly platform: Platform;
|
|
33
34
|
private parse;
|
|
34
35
|
private cleanups;
|
|
36
|
+
private coordinatorPromise?;
|
|
35
37
|
constructor(driver: RawDriverService, platform: Platform, parse: (raw: string) => Element, appId?: string, cleanups?: (() => void)[]);
|
|
38
|
+
private coordinator;
|
|
36
39
|
hierarchy(): Promise<Element>;
|
|
37
40
|
selectors(): Promise<SuggestedSelector[]>;
|
|
38
41
|
tap(selector: ExtendedSelector): Promise<void>;
|
|
@@ -48,9 +51,12 @@ declare class Session {
|
|
|
48
51
|
duration?: number;
|
|
49
52
|
}): Promise<void>;
|
|
50
53
|
scroll(direction: Direction): Promise<void>;
|
|
54
|
+
scrollUntilVisible(selector: ExtendedSelector, opts?: ScrollUntilVisibleOptions): Promise<void>;
|
|
55
|
+
backUntilVisible(selector: ExtendedSelector, opts?: BackUntilVisibleOptions): Promise<void>;
|
|
51
56
|
inputText(text: string): Promise<void>;
|
|
52
57
|
pressKey(key: string): Promise<void>;
|
|
53
58
|
hideKeyboard(): Promise<void>;
|
|
59
|
+
dismissKeyboard(opts?: DismissKeyboardOptions): Promise<void>;
|
|
54
60
|
launch(opts?: LaunchOptions): Promise<void>;
|
|
55
61
|
stop(): Promise<void>;
|
|
56
62
|
kill(): Promise<void>;
|
|
@@ -67,15 +73,38 @@ declare class Session {
|
|
|
67
73
|
loadCookies(path: string): Promise<void>;
|
|
68
74
|
saveAuthState(path: string): Promise<void>;
|
|
69
75
|
loadAuthState(path: string): Promise<void>;
|
|
76
|
+
downloadFile(path: string): Promise<void>;
|
|
77
|
+
uploadFile(selector: Selector, path: string): Promise<void>;
|
|
78
|
+
newTab(url?: string): Promise<string>;
|
|
79
|
+
switchToTab(index: number): Promise<void>;
|
|
80
|
+
closeTab(): Promise<void>;
|
|
81
|
+
getTabIds(): Promise<string[]>;
|
|
82
|
+
getConsoleLogs(): Promise<BrowserConsoleLog[]>;
|
|
83
|
+
getJSErrors(): Promise<BrowserJSError[]>;
|
|
84
|
+
getHAR(): Promise<BrowserHAR>;
|
|
70
85
|
disconnect(): Promise<void>;
|
|
71
86
|
}
|
|
72
87
|
/** Connect to a device and create a persistent session */
|
|
73
88
|
declare function connect(opts: ConnectOptions): Promise<Session>;
|
|
74
89
|
|
|
75
|
-
|
|
90
|
+
type ValidationCode = "MISSING_DEFAULT_EXPORT" | "INVALID_FLOW_DEFINITION" | "FLOW_LOAD_FAILED" | "FLOW_DIRECTORY_MISSING" | "NO_FLOW_FILES" | "STEP_DEFINITION_LOAD_FAILED" | "DUPLICATE_FLOW_NAME" | "INVALID_PLATFORM" | "FLOW_TOO_LONG" | "FLOW_NESTING_TOO_DEEP" | "FLOW_CONDITIONAL_TOO_COMPLEX" | "FLOW_NAME_EMPTY" | "FLOW_MISSING_TAGS" | "GHERKIN_NAME_EMPTY" | "GHERKIN_MISSING_TAGS";
|
|
91
|
+
interface ValidationBase {
|
|
76
92
|
file: string;
|
|
93
|
+
code: ValidationCode;
|
|
94
|
+
suggestedFix?: string;
|
|
95
|
+
docsUrl?: string;
|
|
96
|
+
}
|
|
97
|
+
interface ValidationIssue extends ValidationBase {
|
|
77
98
|
error: string;
|
|
99
|
+
severity: "error";
|
|
100
|
+
}
|
|
101
|
+
interface ValidationWarning extends ValidationBase {
|
|
102
|
+
message: string;
|
|
103
|
+
severity: "warning";
|
|
78
104
|
}
|
|
79
|
-
|
|
105
|
+
type ValidationResult = ValidationIssue | ValidationWarning;
|
|
106
|
+
type ValidationError = ValidationIssue;
|
|
107
|
+
declare function validateFlows(paths: string[]): Promise<ValidationIssue[]>;
|
|
108
|
+
declare function validateProject(flowDir: string): Promise<ValidationResult[]>;
|
|
80
109
|
|
|
81
|
-
export { type ConnectOptions, type Direction, Session, type SuggestedSelector, type ValidationError, connect, validateFlows };
|
|
110
|
+
export { type ConnectOptions, type Direction, Session, type SuggestedSelector, type ValidationError, type ValidationIssue, type ValidationResult, type ValidationWarning, connect, validateFlows, validateProject };
|
package/dist/agent/index.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Session,
|
|
3
3
|
connect
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-S4R4OR7T.js";
|
|
5
|
+
import "../chunk-WQ4GXUUE.js";
|
|
6
|
+
import "../chunk-BF37W5EG.js";
|
|
7
|
+
import "../chunk-AEKDFFPJ.js";
|
|
6
8
|
import {
|
|
7
|
-
validateFlows
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
12
|
-
import "../chunk-
|
|
9
|
+
validateFlows,
|
|
10
|
+
validateProject
|
|
11
|
+
} from "../chunk-IJIASIX5.js";
|
|
12
|
+
import "../chunk-MRH7SK52.js";
|
|
13
|
+
import "../chunk-S2XNAKSO.js";
|
|
14
|
+
import "../chunk-FNDOEMOL.js";
|
|
13
15
|
import "../chunk-GZK22EIE.js";
|
|
14
|
-
import "../chunk-
|
|
16
|
+
import "../chunk-SFBRFB2N.js";
|
|
17
|
+
import "../chunk-3YR4GUGE.js";
|
|
15
18
|
import "../chunk-DGUM43GV.js";
|
|
16
19
|
export {
|
|
17
20
|
Session,
|
|
18
21
|
connect,
|
|
19
|
-
validateFlows
|
|
22
|
+
validateFlows,
|
|
23
|
+
validateProject
|
|
20
24
|
};
|
|
21
25
|
//# sourceMappingURL=index.js.map
|