spana-test 0.0.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/spana-testing/SKILL.md +304 -0
- package/README.md +308 -88
- package/dist/agent/index.d.ts +110 -0
- package/dist/agent/index.js +25 -0
- package/dist/allure-PTTVORQ6.js +124 -0
- package/dist/allure-PTTVORQ6.js.map +1 -0
- package/dist/android-PAPJJWVN.js +34 -0
- package/dist/android-PAPJJWVN.js.map +1 -0
- package/dist/chunk-3FSZNKEF.js +62 -0
- package/dist/chunk-3FSZNKEF.js.map +1 -0
- package/dist/chunk-3YR4GUGE.js +249 -0
- package/dist/chunk-3YR4GUGE.js.map +1 -0
- package/dist/{discover-XIRJTZ7Z.js → chunk-AEKDFFPJ.js} +12 -5
- package/dist/{discover-XIRJTZ7Z.js.map → chunk-AEKDFFPJ.js.map} +1 -1
- package/dist/chunk-BF37W5EG.js +125 -0
- package/dist/chunk-BF37W5EG.js.map +1 -0
- package/dist/chunk-DGUM43GV.js +11 -0
- package/dist/chunk-DGUM43GV.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-CYEDLQJ4.js → chunk-GZK22EIE.js} +76 -102
- package/dist/chunk-GZK22EIE.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-L7MFJF46.js +137 -0
- package/dist/chunk-L7MFJF46.js.map +1 -0
- package/dist/chunk-MRH7SK52.js +134 -0
- package/dist/chunk-MRH7SK52.js.map +1 -0
- package/dist/chunk-P7JQRLP4.js +114 -0
- package/dist/chunk-P7JQRLP4.js.map +1 -0
- package/dist/chunk-S2XNAKSO.js +1087 -0
- package/dist/chunk-S2XNAKSO.js.map +1 -0
- package/dist/chunk-S4R4OR7T.js +358 -0
- package/dist/chunk-S4R4OR7T.js.map +1 -0
- package/dist/chunk-SFBRFB2N.js +277 -0
- package/dist/chunk-SFBRFB2N.js.map +1 -0
- package/dist/chunk-VNYF5BHX.js +494 -0
- 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-WQ4GXUUE.js +2402 -0
- 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 +428 -34
- package/dist/cli.js.map +1 -1
- package/dist/compiler-74VGKZO6.js +312 -0
- package/dist/compiler-74VGKZO6.js.map +1 -0
- package/dist/config-loader-BJJ3IJJ7.js +9 -0
- package/dist/config-loader-BJJ3IJJ7.js.map +1 -0
- package/dist/console-XWKUTP3D.js +164 -0
- package/dist/console-XWKUTP3D.js.map +1 -0
- package/dist/coordinator-BbUjvvnX.d.ts +383 -0
- package/dist/discover-KZKXHZZA.js +14 -0
- package/dist/discover-KZKXHZZA.js.map +1 -0
- package/dist/doctor-command-T2UX5RV5.js +732 -0
- package/dist/doctor-command-T2UX5RV5.js.map +1 -0
- package/dist/element-DZ0HyJ3C.d.ts +25 -0
- package/dist/flow-BUC9Mf8W.d.ts +128 -0
- package/dist/gherkin/steps.d.ts +32 -0
- package/dist/gherkin/steps.js +39 -0
- package/dist/gherkin/steps.js.map +1 -0
- package/dist/{html-GRB34S6X.js → html-GE6Q4DCG.js} +76 -22
- package/dist/html-GE6Q4DCG.js.map +1 -0
- package/dist/index.d.ts +159 -144
- package/dist/index.js +39 -165
- package/dist/index.js.map +1 -1
- package/dist/init-command-GVMRXIMY.js +121 -0
- 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-YZJ4DV3F.js +22 -0
- package/dist/installer-YZJ4DV3F.js.map +1 -0
- package/dist/ios-ZW6XVNLG.js +50 -0
- package/dist/ios-ZW6XVNLG.js.map +1 -0
- package/dist/json-KS67BZYU.js +39 -0
- package/dist/json-KS67BZYU.js.map +1 -0
- package/dist/{junit-NAGZJOGQ.js → junit-HLC62MK6.js} +15 -4
- package/dist/junit-HLC62MK6.js.map +1 -0
- package/dist/provider-A57C3MU6.js +12 -0
- package/dist/provider-A57C3MU6.js.map +1 -0
- package/dist/redact-U72BUBBR.js +77 -0
- package/dist/redact-U72BUBBR.js.map +1 -0
- package/dist/runner-UXNHVVGG.js +20 -0
- package/dist/runner-UXNHVVGG.js.map +1 -0
- package/dist/server-W7OA3DDN.js +530 -0
- package/dist/server-W7OA3DDN.js.map +1 -0
- package/dist/session-TMNOKYLG.js +17 -0
- package/dist/session-TMNOKYLG.js.map +1 -0
- package/dist/studio-command-6VHTHDUK.js +24 -0
- package/dist/studio-command-6VHTHDUK.js.map +1 -0
- package/dist/test-command-AHMOZLV4.js +2852 -0
- package/dist/test-command-AHMOZLV4.js.map +1 -0
- package/dist/validator-35624P7S.js +20 -0
- package/dist/validator-35624P7S.js.map +1 -0
- package/package.json +41 -4
- package/studio-dist/assets/index-DC6DIXfl.js +188 -0
- package/studio-dist/assets/index-DDKsnBwD.css +1 -0
- package/studio-dist/index.html +13 -0
- package/dist/chunk-CYEDLQJ4.js.map +0 -1
- package/dist/chunk-PVNNKPBW.js +0 -64
- package/dist/chunk-PVNNKPBW.js.map +0 -1
- package/dist/chunk-VZZH66U5.js +0 -1781
- package/dist/chunk-VZZH66U5.js.map +0 -1
- package/dist/console-GPV3M3PC.js +0 -71
- package/dist/console-GPV3M3PC.js.map +0 -1
- package/dist/html-GRB34S6X.js.map +0 -1
- package/dist/json-FK2NSRGC.js +0 -20
- package/dist/json-FK2NSRGC.js.map +0 -1
- package/dist/junit-NAGZJOGQ.js.map +0 -1
- package/dist/runner-LBQUCG3K.js +0 -12
- package/dist/session-U7VP5J2C.js +0 -122
- package/dist/session-U7VP5J2C.js.map +0 -1
- package/dist/test-command-WPYLJYIK.js +0 -636
- package/dist/test-command-WPYLJYIK.js.map +0 -1
- package/dist/validator-J4YSBB66.js +0 -33
- package/dist/validator-J4YSBB66.js.map +0 -1
- /package/dist/{runner-LBQUCG3K.js.map → agent/index.js.map} +0 -0
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,47 +8,65 @@ 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
|
|
|
21
24
|
## Quick Start
|
|
22
25
|
|
|
23
26
|
```bash
|
|
27
|
+
npm install spana-test
|
|
28
|
+
# or
|
|
24
29
|
bun add spana-test
|
|
25
30
|
```
|
|
26
31
|
|
|
27
32
|
Create `spana.config.ts`:
|
|
28
33
|
|
|
29
34
|
```ts
|
|
30
|
-
import { defineConfig } from "spana";
|
|
35
|
+
import { defineConfig } from "spana-test";
|
|
31
36
|
|
|
32
37
|
export default defineConfig({
|
|
33
38
|
apps: {
|
|
34
39
|
web: { url: "http://localhost:3000" },
|
|
35
|
-
android: {
|
|
36
|
-
|
|
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
|
+
},
|
|
37
48
|
},
|
|
38
49
|
platforms: ["web", "android"],
|
|
50
|
+
reporters: ["console", "html"],
|
|
51
|
+
artifacts: {
|
|
52
|
+
outputDir: ".spana/artifacts",
|
|
53
|
+
captureOnFailure: true,
|
|
54
|
+
},
|
|
39
55
|
});
|
|
40
56
|
```
|
|
41
57
|
|
|
42
|
-
Create `flows/login.ts`:
|
|
58
|
+
Create `flows/login.flow.ts`:
|
|
43
59
|
|
|
44
60
|
```ts
|
|
45
|
-
import { flow } from "spana";
|
|
61
|
+
import { flow } from "spana-test";
|
|
46
62
|
|
|
47
63
|
export default flow("user can log in", async ({ app, expect }) => {
|
|
48
64
|
await app.tap({ testID: "email-input" });
|
|
49
|
-
await app.
|
|
65
|
+
await app.inputText("user@example.com");
|
|
66
|
+
await app.dismissKeyboard();
|
|
50
67
|
await app.tap({ testID: "password-input" });
|
|
51
|
-
await app.
|
|
68
|
+
await app.inputText("secret");
|
|
69
|
+
await app.dismissKeyboard();
|
|
52
70
|
await app.tap({ testID: "login-button" });
|
|
53
71
|
await expect({ testID: "home-screen" }).toBeVisible();
|
|
54
72
|
});
|
|
@@ -57,86 +75,124 @@ export default flow("user can log in", async ({ app, expect }) => {
|
|
|
57
75
|
Run:
|
|
58
76
|
|
|
59
77
|
```bash
|
|
78
|
+
spana validate-config
|
|
79
|
+
spana validate ./flows
|
|
60
80
|
spana test
|
|
61
81
|
```
|
|
62
82
|
|
|
63
83
|
---
|
|
64
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
|
+
|
|
65
99
|
## Writing Flows
|
|
66
100
|
|
|
67
101
|
### Basic API
|
|
68
102
|
|
|
69
103
|
```ts
|
|
70
|
-
import { flow } from "spana";
|
|
71
|
-
|
|
72
|
-
export default flow("flow name", async ({ app, expect, platform }) => {
|
|
73
|
-
// tap, type, scroll
|
|
74
|
-
await app.tap({ text: "Sign In" });
|
|
75
|
-
await app.typeText("hello");
|
|
76
|
-
await app.scroll({ direction: "down" });
|
|
77
|
-
|
|
78
|
-
// assertions
|
|
79
|
-
await expect({ testID: "welcome" }).toBeVisible();
|
|
80
|
-
await expect({ text: "Welcome" }).toBeVisible();
|
|
81
|
-
|
|
82
|
-
// platform branching
|
|
83
|
-
if (platform === "web") {
|
|
84
|
-
await app.tap({ testID: "web-only-button" });
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### With config
|
|
104
|
+
import { flow } from "spana-test";
|
|
90
105
|
|
|
91
|
-
```ts
|
|
92
106
|
export default flow(
|
|
93
107
|
"checkout flow",
|
|
94
|
-
{
|
|
108
|
+
{
|
|
109
|
+
tags: ["smoke", "payments"],
|
|
110
|
+
platforms: ["android", "ios"],
|
|
111
|
+
timeout: 60_000,
|
|
112
|
+
defaults: {
|
|
113
|
+
waitForIdleTimeout: 250,
|
|
114
|
+
typingDelay: 20,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
95
117
|
async ({ app, expect }) => {
|
|
96
|
-
|
|
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();
|
|
97
129
|
},
|
|
98
130
|
);
|
|
99
131
|
```
|
|
100
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
|
+
|
|
101
135
|
### FlowConfig options
|
|
102
136
|
|
|
103
|
-
| Option | Type
|
|
104
|
-
| ------------ |
|
|
105
|
-
| `tags` | `string[]`
|
|
106
|
-
| `platforms` | `Platform[]`
|
|
107
|
-
| `timeout` | `number`
|
|
108
|
-
| `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
|
+
```
|
|
109
158
|
|
|
110
159
|
---
|
|
111
160
|
|
|
112
161
|
## CLI Commands
|
|
113
162
|
|
|
114
|
-
| Command
|
|
115
|
-
|
|
|
116
|
-
| `spana test [path]`
|
|
117
|
-
| `spana hierarchy`
|
|
118
|
-
| `spana selectors`
|
|
119
|
-
| `spana validate [path]`
|
|
120
|
-
| `spana
|
|
121
|
-
| `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 |
|
|
122
174
|
|
|
123
175
|
### test options
|
|
124
176
|
|
|
125
177
|
```bash
|
|
126
|
-
spana test flows/login.ts
|
|
127
|
-
spana test --platform android,ios
|
|
128
|
-
spana test --
|
|
129
|
-
spana test --grep "log in"
|
|
130
|
-
spana test --reporter
|
|
131
|
-
spana test --
|
|
132
|
-
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
|
|
133
187
|
```
|
|
134
188
|
|
|
135
|
-
###
|
|
189
|
+
### inspection and debugging
|
|
136
190
|
|
|
137
191
|
```bash
|
|
138
192
|
spana hierarchy --platform android --pretty
|
|
139
193
|
spana selectors --platform ios
|
|
194
|
+
spana validate-config
|
|
195
|
+
spana studio --no-open
|
|
140
196
|
```
|
|
141
197
|
|
|
142
198
|
---
|
|
@@ -144,27 +200,58 @@ spana selectors --platform ios
|
|
|
144
200
|
## Configuration
|
|
145
201
|
|
|
146
202
|
```ts
|
|
147
|
-
import { defineConfig } from "spana";
|
|
203
|
+
import { defineConfig } from "spana-test";
|
|
148
204
|
|
|
149
205
|
export default defineConfig({
|
|
150
206
|
apps: {
|
|
151
207
|
web: { url: "http://localhost:3000" },
|
|
152
|
-
android: {
|
|
153
|
-
|
|
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
|
+
},
|
|
217
|
+
},
|
|
218
|
+
execution: {
|
|
219
|
+
web: {
|
|
220
|
+
browser: "chromium",
|
|
221
|
+
headless: true,
|
|
222
|
+
storageState: "./auth/web-user.json",
|
|
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
|
+
},
|
|
154
232
|
},
|
|
155
233
|
platforms: ["web", "android", "ios"],
|
|
156
234
|
flowDir: "./flows",
|
|
157
|
-
reporters: ["console", "json", "html"],
|
|
235
|
+
reporters: ["console", "json", "html", "allure"],
|
|
158
236
|
defaults: {
|
|
159
|
-
waitTimeout: 5000,
|
|
160
|
-
pollInterval: 200,
|
|
161
|
-
settleTimeout: 300,
|
|
162
|
-
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,
|
|
163
249
|
},
|
|
164
250
|
artifacts: {
|
|
165
251
|
outputDir: ".spana/artifacts",
|
|
166
|
-
captureOnFailure: true,
|
|
252
|
+
captureOnFailure: true,
|
|
167
253
|
captureOnSuccess: false,
|
|
254
|
+
captureSteps: false,
|
|
168
255
|
screenshot: true,
|
|
169
256
|
uiHierarchy: true,
|
|
170
257
|
},
|
|
@@ -185,29 +272,106 @@ export default defineConfig({
|
|
|
185
272
|
});
|
|
186
273
|
```
|
|
187
274
|
|
|
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.
|
|
276
|
+
|
|
277
|
+
### Browser runtime helpers (web)
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
import { flow } from "spana-test";
|
|
281
|
+
|
|
282
|
+
export default flow("web dashboard", async ({ app, platform }) => {
|
|
283
|
+
if (platform !== "web") return;
|
|
284
|
+
|
|
285
|
+
await app.loadAuthState("./auth/web-user.json");
|
|
286
|
+
await app.mockNetwork("**/api/dashboard", {
|
|
287
|
+
json: { widgets: ["revenue", "alerts"] },
|
|
288
|
+
});
|
|
289
|
+
await app.blockNetwork("**/analytics/**");
|
|
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());
|
|
302
|
+
await app.saveCookies("./tmp/cookies.json");
|
|
303
|
+
});
|
|
304
|
+
```
|
|
305
|
+
|
|
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.
|
|
325
|
+
|
|
188
326
|
---
|
|
189
327
|
|
|
190
328
|
## Selectors
|
|
191
329
|
|
|
192
|
-
| Selector | Example | Notes
|
|
193
|
-
| -------------------- | --------------------------------- |
|
|
194
|
-
| `testID` | `{ testID: "login-btn" }` | Preferred
|
|
195
|
-
| `text` | `{ text: "Sign In" }` | Visible label text, partial match supported
|
|
196
|
-
| `accessibilityLabel` | `{ accessibilityLabel: "Close" }` | OS accessibility label
|
|
197
|
-
| `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 |
|
|
198
336
|
|
|
199
337
|
Selectors can be combined. When multiple fields are set, all must match.
|
|
200
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
|
+
|
|
201
365
|
---
|
|
202
366
|
|
|
203
367
|
## Agent Integration
|
|
204
368
|
|
|
205
369
|
`spana` is designed for AI agent workflows:
|
|
206
370
|
|
|
207
|
-
- `spana selectors --platform android` returns JSON with element details and suggested selectors
|
|
208
|
-
- `spana hierarchy --platform web --pretty` dumps the
|
|
209
|
-
- `spana validate` exits non-zero on invalid flows
|
|
210
|
-
- `--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
|
|
211
375
|
|
|
212
376
|
Example agent loop:
|
|
213
377
|
|
|
@@ -216,29 +380,85 @@ Example agent loop:
|
|
|
216
380
|
spana selectors --platform web | jq '.[] | select(.testID != null)'
|
|
217
381
|
|
|
218
382
|
# 2. run a specific flow with JSON output
|
|
219
|
-
spana test flows/login.ts --reporter json 2>&1 | jq '.results'
|
|
383
|
+
spana test flows/login.flow.ts --reporter json 2>&1 | jq '.results'
|
|
220
384
|
```
|
|
221
385
|
|
|
222
386
|
---
|
|
223
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
|
|
398
|
+
```
|
|
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
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
224
443
|
## Architecture
|
|
225
444
|
|
|
226
445
|
spana uses a layered architecture: CLI -> TestRunner -> PlatformOrchestrator -> SmartLayer -> RawDriver.
|
|
227
446
|
|
|
228
|
-
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.
|
|
229
448
|
|
|
230
|
-
See [ARCHITECTURE.md](
|
|
449
|
+
See [ARCHITECTURE.md](https://github.com/wezter96/spana/blob/main/ARCHITECTURE.md) for details.
|
|
231
450
|
|
|
232
451
|
---
|
|
233
452
|
|
|
234
453
|
## Platforms
|
|
235
454
|
|
|
236
|
-
| Platform | Driver
|
|
237
|
-
| ------------- |
|
|
238
|
-
| Web / RN Web | Playwright (CDP)
|
|
239
|
-
| Android | UiAutomator2 HTTP client
|
|
240
|
-
| iOS Simulator | WebDriverAgent HTTP client
|
|
241
|
-
| 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 |
|
|
242
462
|
|
|
243
463
|
---
|
|
244
464
|
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
import 'effect';
|
|
4
|
+
|
|
5
|
+
type Direction = "up" | "down" | "left" | "right";
|
|
6
|
+
interface ConnectOptions {
|
|
7
|
+
platform: Platform;
|
|
8
|
+
device?: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
packageName?: string;
|
|
11
|
+
bundleId?: string;
|
|
12
|
+
headless?: boolean;
|
|
13
|
+
browser?: BrowserName;
|
|
14
|
+
storageState?: string;
|
|
15
|
+
verboseLogging?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface SuggestedSelector {
|
|
18
|
+
suggestedSelector: Selector;
|
|
19
|
+
elementType?: string;
|
|
20
|
+
text?: string;
|
|
21
|
+
accessibilityLabel?: string;
|
|
22
|
+
bounds: {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
};
|
|
28
|
+
id?: string;
|
|
29
|
+
}
|
|
30
|
+
declare class Session {
|
|
31
|
+
private driver;
|
|
32
|
+
private appId;
|
|
33
|
+
readonly platform: Platform;
|
|
34
|
+
private parse;
|
|
35
|
+
private cleanups;
|
|
36
|
+
private coordinatorPromise?;
|
|
37
|
+
constructor(driver: RawDriverService, platform: Platform, parse: (raw: string) => Element, appId?: string, cleanups?: (() => void)[]);
|
|
38
|
+
private coordinator;
|
|
39
|
+
hierarchy(): Promise<Element>;
|
|
40
|
+
selectors(): Promise<SuggestedSelector[]>;
|
|
41
|
+
tap(selector: ExtendedSelector): Promise<void>;
|
|
42
|
+
tapXY(x: number, y: number): Promise<void>;
|
|
43
|
+
doubleTap(selector: ExtendedSelector): Promise<void>;
|
|
44
|
+
longPress(selector: ExtendedSelector, opts?: {
|
|
45
|
+
duration?: number;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
longPressXY(x: number, y: number, opts?: {
|
|
48
|
+
duration?: number;
|
|
49
|
+
}): Promise<void>;
|
|
50
|
+
swipe(direction: Direction, opts?: {
|
|
51
|
+
duration?: number;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
scroll(direction: Direction): Promise<void>;
|
|
54
|
+
scrollUntilVisible(selector: ExtendedSelector, opts?: ScrollUntilVisibleOptions): Promise<void>;
|
|
55
|
+
backUntilVisible(selector: ExtendedSelector, opts?: BackUntilVisibleOptions): Promise<void>;
|
|
56
|
+
inputText(text: string): Promise<void>;
|
|
57
|
+
pressKey(key: string): Promise<void>;
|
|
58
|
+
hideKeyboard(): Promise<void>;
|
|
59
|
+
dismissKeyboard(opts?: DismissKeyboardOptions): Promise<void>;
|
|
60
|
+
launch(opts?: LaunchOptions): Promise<void>;
|
|
61
|
+
stop(): Promise<void>;
|
|
62
|
+
kill(): Promise<void>;
|
|
63
|
+
clearState(): Promise<void>;
|
|
64
|
+
openLink(url: string): Promise<void>;
|
|
65
|
+
back(): Promise<void>;
|
|
66
|
+
screenshot(): Promise<Uint8Array>;
|
|
67
|
+
evaluate<T = unknown>(fn: ((...args: any[]) => T) | string, ...args: any[]): Promise<T>;
|
|
68
|
+
mockNetwork(matcher: BrowserRouteMatcher, response: BrowserMockResponse): Promise<void>;
|
|
69
|
+
blockNetwork(matcher: BrowserRouteMatcher): Promise<void>;
|
|
70
|
+
clearNetworkMocks(): Promise<void>;
|
|
71
|
+
setNetworkConditions(conditions: BrowserNetworkConditions): Promise<void>;
|
|
72
|
+
saveCookies(path: string): Promise<void>;
|
|
73
|
+
loadCookies(path: string): Promise<void>;
|
|
74
|
+
saveAuthState(path: string): Promise<void>;
|
|
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>;
|
|
85
|
+
disconnect(): Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
/** Connect to a device and create a persistent session */
|
|
88
|
+
declare function connect(opts: ConnectOptions): Promise<Session>;
|
|
89
|
+
|
|
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 {
|
|
92
|
+
file: string;
|
|
93
|
+
code: ValidationCode;
|
|
94
|
+
suggestedFix?: string;
|
|
95
|
+
docsUrl?: string;
|
|
96
|
+
}
|
|
97
|
+
interface ValidationIssue extends ValidationBase {
|
|
98
|
+
error: string;
|
|
99
|
+
severity: "error";
|
|
100
|
+
}
|
|
101
|
+
interface ValidationWarning extends ValidationBase {
|
|
102
|
+
message: string;
|
|
103
|
+
severity: "warning";
|
|
104
|
+
}
|
|
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[]>;
|
|
109
|
+
|
|
110
|
+
export { type ConnectOptions, type Direction, Session, type SuggestedSelector, type ValidationError, type ValidationIssue, type ValidationResult, type ValidationWarning, connect, validateFlows, validateProject };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Session,
|
|
3
|
+
connect
|
|
4
|
+
} from "../chunk-S4R4OR7T.js";
|
|
5
|
+
import "../chunk-WQ4GXUUE.js";
|
|
6
|
+
import "../chunk-BF37W5EG.js";
|
|
7
|
+
import "../chunk-AEKDFFPJ.js";
|
|
8
|
+
import {
|
|
9
|
+
validateFlows,
|
|
10
|
+
validateProject
|
|
11
|
+
} from "../chunk-IJIASIX5.js";
|
|
12
|
+
import "../chunk-MRH7SK52.js";
|
|
13
|
+
import "../chunk-S2XNAKSO.js";
|
|
14
|
+
import "../chunk-FNDOEMOL.js";
|
|
15
|
+
import "../chunk-GZK22EIE.js";
|
|
16
|
+
import "../chunk-SFBRFB2N.js";
|
|
17
|
+
import "../chunk-3YR4GUGE.js";
|
|
18
|
+
import "../chunk-DGUM43GV.js";
|
|
19
|
+
export {
|
|
20
|
+
Session,
|
|
21
|
+
connect,
|
|
22
|
+
validateFlows,
|
|
23
|
+
validateProject
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=index.js.map
|