@testingbot/mobilewright-driver 0.1.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/LICENSE +202 -0
- package/README.md +211 -0
- package/dist/actions.d.ts +25 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +76 -0
- package/dist/actions.js.map +1 -0
- package/dist/app-storage.d.ts +20 -0
- package/dist/app-storage.d.ts.map +1 -0
- package/dist/app-storage.js +68 -0
- package/dist/app-storage.js.map +1 -0
- package/dist/capabilities.d.ts +27 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +120 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/ci.d.ts +8 -0
- package/dist/ci.d.ts.map +1 -0
- package/dist/ci.js +46 -0
- package/dist/ci.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +43 -0
- package/dist/cli.js.map +1 -0
- package/dist/device-catalog.d.ts +37 -0
- package/dist/device-catalog.d.ts.map +1 -0
- package/dist/device-catalog.js +159 -0
- package/dist/device-catalog.js.map +1 -0
- package/dist/driver.d.ts +80 -0
- package/dist/driver.d.ts.map +1 -0
- package/dist/driver.js +646 -0
- package/dist/driver.js.map +1 -0
- package/dist/errors.d.ts +41 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +104 -0
- package/dist/errors.js.map +1 -0
- package/dist/hierarchy.d.ts +10 -0
- package/dist/hierarchy.d.ts.map +1 -0
- package/dist/hierarchy.js +103 -0
- package/dist/hierarchy.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/init.d.ts +19 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +108 -0
- package/dist/init.js.map +1 -0
- package/dist/keepalive.d.ts +16 -0
- package/dist/keepalive.d.ts.map +1 -0
- package/dist/keepalive.js +56 -0
- package/dist/keepalive.js.map +1 -0
- package/dist/keys.d.ts +32 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +117 -0
- package/dist/keys.js.map +1 -0
- package/dist/observer.d.ts +55 -0
- package/dist/observer.d.ts.map +1 -0
- package/dist/observer.js +148 -0
- package/dist/observer.js.map +1 -0
- package/dist/options.d.ts +154 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +49 -0
- package/dist/options.js.map +1 -0
- package/dist/rest-api.d.ts +67 -0
- package/dist/rest-api.d.ts.map +1 -0
- package/dist/rest-api.js +117 -0
- package/dist/rest-api.js.map +1 -0
- package/dist/run-log.d.ts +56 -0
- package/dist/run-log.d.ts.map +1 -0
- package/dist/run-log.js +72 -0
- package/dist/run-log.js.map +1 -0
- package/dist/tunnel.d.ts +13 -0
- package/dist/tunnel.d.ts.map +1 -0
- package/dist/tunnel.js +47 -0
- package/dist/tunnel.js.map +1 -0
- package/dist/version.d.ts +4 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +7 -0
- package/dist/version.js.map +1 -0
- package/dist/webdriver-client.d.ts +43 -0
- package/dist/webdriver-client.d.ts.map +1 -0
- package/dist/webdriver-client.js +109 -0
- package/dist/webdriver-client.js.map +1 -0
- package/dist/webview.d.ts +16 -0
- package/dist/webview.d.ts.map +1 -0
- package/dist/webview.js +109 -0
- package/dist/webview.js.map +1 -0
- package/package.json +69 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 TestingBot
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# @testingbot/mobilewright-driver
|
|
2
|
+
|
|
3
|
+
Run [Mobilewright](https://github.com/mobile-next/mobilewright) mobile tests on [TestingBot](https://testingbot.com)'s device cloud — real iOS/Android devices, iOS simulators, and Android emulators.
|
|
4
|
+
|
|
5
|
+
Requires `mobilewright >= 0.0.53` (the first release that accepts driver instances) and Node >= 18.
|
|
6
|
+
|
|
7
|
+
## Quickstart
|
|
8
|
+
|
|
9
|
+
**One command:**
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx @testingbot/mobilewright-driver init
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
answers a few questions and writes `mobilewright.config.ts` plus a sample
|
|
16
|
+
test (add `--yes` for defaults). Or set up manually:
|
|
17
|
+
|
|
18
|
+
**1. Install** (in your test project):
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
npm install --save-dev mobilewright @mobilewright/test @testingbot/mobilewright-driver
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**2. Get your credentials** from [testingbot.com/members/user/edit](https://testingbot.com/members/user/edit):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
export TESTINGBOT_KEY=...
|
|
28
|
+
export TESTINGBOT_SECRET=...
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**3. Create `mobilewright.config.ts`:**
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { defineConfig } from 'mobilewright';
|
|
35
|
+
import { TestingBotDriver } from '@testingbot/mobilewright-driver';
|
|
36
|
+
|
|
37
|
+
export default defineConfig({
|
|
38
|
+
testDir: '.',
|
|
39
|
+
bundleId: 'com.example.MyApp',
|
|
40
|
+
driver: new TestingBotDriver({
|
|
41
|
+
// TestingBot sessions start with the app pre-installed — declare it here.
|
|
42
|
+
// Local paths (.apk / .ipa / simulator .zip) upload automatically.
|
|
43
|
+
apps: {
|
|
44
|
+
android: './build/app.apk',
|
|
45
|
+
'ios-simulator': './build/app-sim.zip',
|
|
46
|
+
'ios-real': './build/app.ipa', // must be test-signed for real devices
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
|
+
projects: [
|
|
50
|
+
{ name: 'android', use: { platform: 'android', deviceType: 'emulator' } },
|
|
51
|
+
{ name: 'ios', use: { platform: 'ios', deviceType: 'real', osVersion: '>=17' } },
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**4. Write a test** (`app.test.ts`):
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import { test, expect } from '@mobilewright/test';
|
|
60
|
+
|
|
61
|
+
test('shows the welcome screen', async ({ device, screen, bundleId }) => {
|
|
62
|
+
await device.launchApp(bundleId);
|
|
63
|
+
await expect(screen.getByText('Welcome')).toBeVisible();
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**5. Run:**
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
npx mobilewright test
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Each device slot maps to a TestingBot session on your [dashboard](https://testingbot.com/members), with video and pass/fail reported automatically. Prefix with `DEBUG=testingbot:*` to see everything the driver does.
|
|
74
|
+
|
|
75
|
+
## Selecting devices
|
|
76
|
+
|
|
77
|
+
Device selection comes from the mobilewright project config (`use` block):
|
|
78
|
+
|
|
79
|
+
| Key | Example | Notes |
|
|
80
|
+
| --- | --- | --- |
|
|
81
|
+
| `platform` | `'ios'` \| `'android'` | required |
|
|
82
|
+
| `deviceType` | `'real'` \| `'simulator'` \| `'emulator'` | default: virtual device |
|
|
83
|
+
| `deviceName` | `/iPhone 1[45]/`, `/pixel/i` | regex, matched against TestingBot's device catalogs |
|
|
84
|
+
| `osVersion` | `'17'`, `'17.4'`, `'>=16 <18'` | exact, prefix, or range expression |
|
|
85
|
+
| `deviceId` | `'2241'` | pin one specific physical device (id from `GET /v1/devices`) |
|
|
86
|
+
|
|
87
|
+
Regexes and version ranges work on both real and virtual devices: real devices resolve against the live physical catalog (`/v1/devices` — idle devices preferred; if the chosen device is busy, TestingBot queues the session until it frees up), virtual ones against the simulator/emulator catalog (`/v1/browsers`, newest matching OS version wins).
|
|
88
|
+
|
|
89
|
+
## Sessions, naming, and reporting
|
|
90
|
+
|
|
91
|
+
- By default a device slot's TestingBot session is reused across tests (fast: you pay device startup once). Sessions that hosted exactly one test are named after that test with its own pass/fail; sessions that hosted several get a run summary (e.g. `12/12 tests passed`).
|
|
92
|
+
- Set **`sessionPerTest: true`** for one session, video, and named verdict **per test** — the clearest dashboard, at the cost of device startup on every test.
|
|
93
|
+
- Failure messages are reported to the session's status message; `build` groups sessions on the dashboard and **defaults automatically from CI environments** (GitHub Actions, GitLab, CircleCI, Buildkite, Bitrise, Travis, Azure DevOps, Jenkins, TeamCity → e.g. `owner/repo #123`), or from a `TESTINGBOT_BUILD` variable.
|
|
94
|
+
|
|
95
|
+
## All options
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
new TestingBotDriver({
|
|
99
|
+
apps: { android: './build/app.apk' }, // app under test, most specific key wins
|
|
100
|
+
// ('ios-real' beats 'ios'); tb:// URLs allowed
|
|
101
|
+
key: '...', // default: TESTINGBOT_KEY env
|
|
102
|
+
secret: '...', // default: TESTINGBOT_SECRET env
|
|
103
|
+
sessionPerTest: false, // true = fresh session (and video) per test
|
|
104
|
+
name: 'checkout flow', // session name (default 'mobilewright'; per-test names override)
|
|
105
|
+
build: 'ci-1234', // default: auto-detected from CI env / TESTINGBOT_BUILD
|
|
106
|
+
testResults: 'on', // 'off' disables pass/fail reporting
|
|
107
|
+
|
|
108
|
+
allocationTimeout: 395_000, // ms to wait for a device (TestingBot queues busy devices)
|
|
109
|
+
idleTimeout: 230, // seconds before TestingBot reaps an idle session
|
|
110
|
+
maxDuration: 1800, // max session length in seconds
|
|
111
|
+
appiumVersion: 'latest', // pin the Appium version TestingBot uses
|
|
112
|
+
|
|
113
|
+
timeZone: 'Europe/Brussels', // device timezone (tz database name)
|
|
114
|
+
geoCountryCode: 'DE', // route device traffic via a proxy in this country
|
|
115
|
+
throttleNetwork: '3G', // or { downloadSpeed, uploadSpeed, latency, loss }
|
|
116
|
+
screenshots: true, // screenshot at every step (default false)
|
|
117
|
+
video: true, // session video (default true)
|
|
118
|
+
recordLogs: 'strip-parameters',// command logs: true | false | 'strip-parameters'
|
|
119
|
+
public: false, // make results publicly accessible
|
|
120
|
+
extra: 'commit=abc123', // custom metadata on the test detail page
|
|
121
|
+
tabletOnly: false, // restrict allocation to tablets
|
|
122
|
+
phoneOnly: false, // ...or to phones
|
|
123
|
+
|
|
124
|
+
capabilities: {}, // extra Appium capabilities (escape hatch)
|
|
125
|
+
tbOptions: {}, // extra tb:options entries (escape hatch)
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Testing localhost / staging servers (TestingBot Tunnel)
|
|
130
|
+
|
|
131
|
+
Either run a [TestingBot Tunnel](https://testingbot.com/support/tunnel) yourself and pass its identifier:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
driver: new TestingBotDriver({ tunnelIdentifier: 'my-tunnel' })
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
or let the driver manage one around the run (requires Java and `npm install --save-dev testingbot-tunnel-launcher`):
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
driver: new TestingBotDriver({ tunnel: true }) // anonymous tunnel
|
|
141
|
+
driver: new TestingBotDriver({ tunnel: { identifier: 'ci-42' } }) // named tunnel
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The driver starts the tunnel before any device is allocated and closes it after the run.
|
|
145
|
+
|
|
146
|
+
## Running in CI (GitHub Actions example)
|
|
147
|
+
|
|
148
|
+
```yaml
|
|
149
|
+
jobs:
|
|
150
|
+
mobile-tests:
|
|
151
|
+
runs-on: ubuntu-latest
|
|
152
|
+
steps:
|
|
153
|
+
- uses: actions/checkout@v4
|
|
154
|
+
- uses: actions/setup-node@v4
|
|
155
|
+
with: { node-version: 20, cache: npm }
|
|
156
|
+
- run: npm ci
|
|
157
|
+
- run: npx mobilewright test
|
|
158
|
+
env:
|
|
159
|
+
TESTINGBOT_KEY: ${{ secrets.TESTINGBOT_KEY }}
|
|
160
|
+
TESTINGBOT_SECRET: ${{ secrets.TESTINGBOT_SECRET }}
|
|
161
|
+
# build name auto-detects as "owner/repo #run" — no config needed
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Troubleshooting
|
|
165
|
+
|
|
166
|
+
| Symptom | Cause / fix |
|
|
167
|
+
| --- | --- |
|
|
168
|
+
| `TestingBot credentials are missing` | Set `TESTINGBOT_KEY` / `TESTINGBOT_SECRET`, or pass `{ key, secret }`. |
|
|
169
|
+
| `TestingBot sessions must start with an app` | Declare the app in the driver's `apps` option (per platform / device type). |
|
|
170
|
+
| `No TestingBot real device matches ...` / `No TestingBot simulator matches ...` | The criteria matched nothing in the catalog — check [available devices](https://testingbot.com/support/devices), loosen `osVersion`/`deviceName`. |
|
|
171
|
+
| Allocation waits for minutes | The matching device is busy; TestingBot queues the session until it frees up (bounded by `allocationTimeout`). |
|
|
172
|
+
| `... is a simulator-only build and cannot be installed on a real device` | Build a test-signed `.ipa` for `deviceType: 'real'` projects. |
|
|
173
|
+
| `cannot install "..." mid-session` | TestingBot has no mid-session installs — point `installApps` and the driver's `apps` at the same build. |
|
|
174
|
+
| Modifier chords fail on iOS | XCUITest cannot hold modifier keys; chords are Android-only (`clearText()` handles iOS differently). |
|
|
175
|
+
| Sessions show the run summary instead of a test name | The session hosted several tests; use `sessionPerTest: true` for guaranteed per-test naming. |
|
|
176
|
+
| `DEBUG=testingbot:*` | Prints every allocation, hub command, upload, and report the driver performs. |
|
|
177
|
+
|
|
178
|
+
## How it maps to TestingBot
|
|
179
|
+
|
|
180
|
+
| mobilewright concept | TestingBot implementation |
|
|
181
|
+
| --- | --- |
|
|
182
|
+
| device allocation | Appium session on `hub.testingbot.com` (the session UUID is the device id); busy devices queue server-side |
|
|
183
|
+
| app install | uploaded to TestingBot storage at allocation time and passed as `appium:app` — no mid-session installs |
|
|
184
|
+
| taps/swipes/gestures | W3C pointer actions |
|
|
185
|
+
| view hierarchy | Appium page source, mapped to mobilewright's `ViewNode` tree |
|
|
186
|
+
| webviews | Appium contexts (`webViewBridge`) |
|
|
187
|
+
| pass/fail reporting | `PUT /v1/tests/:session` via the `TestObserver` hooks |
|
|
188
|
+
| video | recorded by TestingBot; `startRecording({ output })` downloads the MP4 locally at run end |
|
|
189
|
+
|
|
190
|
+
## Current limitations
|
|
191
|
+
|
|
192
|
+
- One TestingBot session may host several mobilewright tests unless `sessionPerTest: true`; multi-test sessions report the run-level verdict.
|
|
193
|
+
- Modifier key chords (`pressKeys(['ctrl+a'])`) work on Android only — XCUITest cannot hold modifier keys.
|
|
194
|
+
- `pressButton` on iOS supports `HOME`, `VOLUME_UP`, `VOLUME_DOWN`; `listApps()` reports the foreground app only.
|
|
195
|
+
- Screenshots are always PNG. `applyDeviceSettings` turns Android animations off best-effort via `mobile: shell` (a no-op on iOS).
|
|
196
|
+
- Real iOS devices need a test-signed `.ipa`; simulator builds are rejected on real devices with a clear error.
|
|
197
|
+
- While attached to a webview, the session's single Appium context is the web layer.
|
|
198
|
+
|
|
199
|
+
## Development
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
npm install
|
|
203
|
+
npm test # unit + FakeHub integration tests (no credentials needed)
|
|
204
|
+
npm run build
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Live e2e tests against a real TestingBot account live in `e2e/` (see `e2e/mobilewright.config.ts`).
|
|
208
|
+
|
|
209
|
+
## License
|
|
210
|
+
|
|
211
|
+
Apache-2.0
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { GestureSequence, ScreenSize, SwipeDirection, SwipeOptions } from '@mobilewright/protocol';
|
|
2
|
+
/**
|
|
3
|
+
* W3C action-sequence builders. Coordinates are passed through in the same
|
|
4
|
+
* space the view hierarchy reports (iOS points, Android pixels) — Appium's
|
|
5
|
+
* input pipeline uses the same space, which is what keeps bounds-center taps
|
|
6
|
+
* landing where the hierarchy says the element is.
|
|
7
|
+
*/
|
|
8
|
+
type W3CAction = Record<string, unknown>;
|
|
9
|
+
interface PointerSource {
|
|
10
|
+
type: 'pointer';
|
|
11
|
+
id: string;
|
|
12
|
+
parameters: {
|
|
13
|
+
pointerType: 'touch';
|
|
14
|
+
};
|
|
15
|
+
actions: W3CAction[];
|
|
16
|
+
}
|
|
17
|
+
export declare function tapActions(x: number, y: number): PointerSource[];
|
|
18
|
+
export declare function doubleTapActions(x: number, y: number): PointerSource[];
|
|
19
|
+
export declare function longPressActions(x: number, y: number, duration?: number): PointerSource[];
|
|
20
|
+
export declare function swipeActions(direction: SwipeDirection, screen: ScreenSize, opts?: SwipeOptions): PointerSource[];
|
|
21
|
+
/** Multi-finger gesture: each pointer path becomes one W3C input source,
|
|
22
|
+
* with `time` offsets converted to per-segment move durations. */
|
|
23
|
+
export declare function gestureActions(gestures: GestureSequence): PointerSource[];
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAExG;;;;;GAKG;AAEH,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEzC,UAAU,aAAa;IACrB,IAAI,EAAE,SAAS,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE;QAAE,WAAW,EAAE,OAAO,CAAA;KAAE,CAAC;IACrC,OAAO,EAAE,SAAS,EAAE,CAAC;CACtB;AAYD,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,EAAE,CAEhE;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,aAAa,EAAE,CAMtE;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,QAAQ,SAAM,GAAG,aAAa,EAAE,CAEtF;AAED,wBAAgB,YAAY,CAC1B,SAAS,EAAE,cAAc,EACzB,MAAM,EAAE,UAAU,EAClB,IAAI,GAAE,YAAiB,GACtB,aAAa,EAAE,CA2BjB;AAED;mEACmE;AACnE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,aAAa,EAAE,CAgBzE"}
|
package/dist/actions.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
function pointerSource(id, actions) {
|
|
2
|
+
return { type: 'pointer', id, parameters: { pointerType: 'touch' }, actions };
|
|
3
|
+
}
|
|
4
|
+
const move = (x, y, duration = 0) => ({ type: 'pointerMove', duration, x: Math.round(x), y: Math.round(y), origin: 'viewport' });
|
|
5
|
+
const down = () => ({ type: 'pointerDown', button: 0 });
|
|
6
|
+
const up = () => ({ type: 'pointerUp', button: 0 });
|
|
7
|
+
const pause = (duration) => ({ type: 'pause', duration });
|
|
8
|
+
export function tapActions(x, y) {
|
|
9
|
+
return [pointerSource('finger1', [move(x, y), down(), pause(50), up()])];
|
|
10
|
+
}
|
|
11
|
+
export function doubleTapActions(x, y) {
|
|
12
|
+
return [pointerSource('finger1', [
|
|
13
|
+
move(x, y), down(), pause(50), up(),
|
|
14
|
+
pause(80),
|
|
15
|
+
down(), pause(50), up(),
|
|
16
|
+
])];
|
|
17
|
+
}
|
|
18
|
+
export function longPressActions(x, y, duration = 800) {
|
|
19
|
+
return [pointerSource('finger1', [move(x, y), down(), pause(duration), up()])];
|
|
20
|
+
}
|
|
21
|
+
export function swipeActions(direction, screen, opts = {}) {
|
|
22
|
+
const startX = opts.startX ?? screen.width / 2;
|
|
23
|
+
const startY = opts.startY ?? screen.height / 2;
|
|
24
|
+
const defaultDistance = (direction === 'up' || direction === 'down' ? screen.height : screen.width) * 0.5;
|
|
25
|
+
const distance = opts.distance ?? defaultDistance;
|
|
26
|
+
const duration = opts.duration ?? 300;
|
|
27
|
+
let endX = startX;
|
|
28
|
+
let endY = startY;
|
|
29
|
+
switch (direction) {
|
|
30
|
+
case 'up':
|
|
31
|
+
endY = startY - distance;
|
|
32
|
+
break;
|
|
33
|
+
case 'down':
|
|
34
|
+
endY = startY + distance;
|
|
35
|
+
break;
|
|
36
|
+
case 'left':
|
|
37
|
+
endX = startX - distance;
|
|
38
|
+
break;
|
|
39
|
+
case 'right':
|
|
40
|
+
endX = startX + distance;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
const clamp = (v, max) => Math.min(Math.max(v, 0), max - 1);
|
|
44
|
+
endX = clamp(endX, screen.width);
|
|
45
|
+
endY = clamp(endY, screen.height);
|
|
46
|
+
return [pointerSource('finger1', [
|
|
47
|
+
move(startX, startY),
|
|
48
|
+
down(),
|
|
49
|
+
pause(50),
|
|
50
|
+
move(endX, endY, duration),
|
|
51
|
+
pause(50),
|
|
52
|
+
up(),
|
|
53
|
+
])];
|
|
54
|
+
}
|
|
55
|
+
/** Multi-finger gesture: each pointer path becomes one W3C input source,
|
|
56
|
+
* with `time` offsets converted to per-segment move durations. */
|
|
57
|
+
export function gestureActions(gestures) {
|
|
58
|
+
return gestures.pointers.map((path, i) => {
|
|
59
|
+
if (path.length === 0)
|
|
60
|
+
return pointerSource(`finger${i + 1}`, []);
|
|
61
|
+
const startTime = path[0].time ?? 0;
|
|
62
|
+
const actions = [];
|
|
63
|
+
if (startTime > 0)
|
|
64
|
+
actions.push(pause(startTime)); // staggered finger start
|
|
65
|
+
actions.push(move(path[0].x, path[0].y), down());
|
|
66
|
+
let lastTime = startTime;
|
|
67
|
+
for (const point of path.slice(1)) {
|
|
68
|
+
const time = point.time ?? lastTime;
|
|
69
|
+
actions.push(move(point.x, point.y, Math.max(time - lastTime, 0)));
|
|
70
|
+
lastTime = time;
|
|
71
|
+
}
|
|
72
|
+
actions.push(up());
|
|
73
|
+
return pointerSource(`finger${i + 1}`, actions);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAkBA,SAAS,aAAa,CAAC,EAAU,EAAE,OAAoB;IACrD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC;AAChF,CAAC;AAED,MAAM,IAAI,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,QAAQ,GAAG,CAAC,EAAa,EAAE,CAC7D,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;AAC9F,MAAM,IAAI,GAAG,GAAc,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AACnE,MAAM,EAAE,GAAG,GAAc,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;AAC/D,MAAM,KAAK,GAAG,CAAC,QAAgB,EAAa,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AAE7E,MAAM,UAAU,UAAU,CAAC,CAAS,EAAE,CAAS;IAC7C,OAAO,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,KAA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ClE,MAAM,SAAS,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC,IAAI,IAAI,CAAC,CAAC;QACrC,MAAM,OAAO,GAAgB,EAAE,CAAC;QAChC,IAAI,SAAS,GAAG,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,yBAAyB;QAC5E,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,IAAI,QAAQ,GAAG,SAAS,CAAC;QACzB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,QAAQ,CAAC;YACpC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YACnE,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QACnB,OAAO,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DeviceType } from '@mobilewright/protocol';
|
|
2
|
+
import { type RestApiClient, type StorageEntry } from './rest-api.js';
|
|
3
|
+
/**
|
|
4
|
+
* Uploads app binaries to TestingBot storage and caches by content hash so
|
|
5
|
+
* a run's many install calls (one per pooled slot) upload each binary once.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AppStorage {
|
|
8
|
+
private readonly api;
|
|
9
|
+
/** sha256 of file contents -> settled storage entry. */
|
|
10
|
+
private readonly uploads;
|
|
11
|
+
constructor(api: RestApiClient);
|
|
12
|
+
/**
|
|
13
|
+
* Upload (or reuse) the app at `path` and return its tb:// URL, validated
|
|
14
|
+
* against the target device type (a simulator-only iOS build cannot install
|
|
15
|
+
* on a real device and vice versa is likely a signing problem).
|
|
16
|
+
*/
|
|
17
|
+
ensureUploaded(path: string, targetType: DeviceType | undefined): Promise<StorageEntry>;
|
|
18
|
+
private uploadAndAwait;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=app-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-storage.d.ts","sourceRoot":"","sources":["../src/app-storage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAU,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAO9E;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAgB;IACpC,wDAAwD;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4C;gBAExD,GAAG,EAAE,aAAa;IAI9B;;;;OAIG;IACG,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC,YAAY,CAAC;YA0B/E,cAAc;CAuB7B"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import createDebug from 'debug';
|
|
3
|
+
import { sha256 } from './rest-api.js';
|
|
4
|
+
const debug = createDebug('testingbot:storage');
|
|
5
|
+
const PROCESSING_POLL_MS = 2_000;
|
|
6
|
+
const PROCESSING_TIMEOUT_MS = 120_000;
|
|
7
|
+
/**
|
|
8
|
+
* Uploads app binaries to TestingBot storage and caches by content hash so
|
|
9
|
+
* a run's many install calls (one per pooled slot) upload each binary once.
|
|
10
|
+
*/
|
|
11
|
+
export class AppStorage {
|
|
12
|
+
api;
|
|
13
|
+
/** sha256 of file contents -> settled storage entry. */
|
|
14
|
+
uploads = new Map();
|
|
15
|
+
constructor(api) {
|
|
16
|
+
this.api = api;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Upload (or reuse) the app at `path` and return its tb:// URL, validated
|
|
20
|
+
* against the target device type (a simulator-only iOS build cannot install
|
|
21
|
+
* on a real device and vice versa is likely a signing problem).
|
|
22
|
+
*/
|
|
23
|
+
async ensureUploaded(path, targetType) {
|
|
24
|
+
const data = await readFile(path);
|
|
25
|
+
if (data.length < 4 || data.readUInt16BE(0) !== 0x504b) {
|
|
26
|
+
// .ipa, .apk and .zip are all ZIP containers ("PK").
|
|
27
|
+
throw new Error(`TestingBotDriver: "${path}" does not look like an app package (.apk/.ipa/.zip expected).`);
|
|
28
|
+
}
|
|
29
|
+
const hash = sha256(data);
|
|
30
|
+
let pending = this.uploads.get(hash);
|
|
31
|
+
if (!pending) {
|
|
32
|
+
pending = this.uploadAndAwait(path);
|
|
33
|
+
this.uploads.set(hash, pending);
|
|
34
|
+
pending.catch(() => this.uploads.delete(hash)); // allow retry after failure
|
|
35
|
+
}
|
|
36
|
+
const entry = await pending;
|
|
37
|
+
if (entry.sim_only && targetType === 'real') {
|
|
38
|
+
throw new Error(`TestingBotDriver: "${path}" is a simulator-only build and cannot be installed on a real device. ` +
|
|
39
|
+
'Build a device .ipa (and make sure it is test-signed) for deviceType: "real" projects.');
|
|
40
|
+
}
|
|
41
|
+
return entry;
|
|
42
|
+
}
|
|
43
|
+
async uploadAndAwait(path) {
|
|
44
|
+
// POST /storage answers with only {app_url}; state/url/sim_only exist
|
|
45
|
+
// only on GET /storage/{appkey}, so metadata always comes from polling.
|
|
46
|
+
const uploaded = await this.api.uploadApp(path);
|
|
47
|
+
debug('uploaded %s -> %s', path, uploaded.app_url);
|
|
48
|
+
const deadline = Date.now() + PROCESSING_TIMEOUT_MS;
|
|
49
|
+
let entry;
|
|
50
|
+
for (;;) {
|
|
51
|
+
try {
|
|
52
|
+
entry = await this.api.getStorageEntry(uploaded.app_url);
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
debug('GET storage entry failed: %s', err);
|
|
56
|
+
}
|
|
57
|
+
if (entry && entry.state !== 'PROCESSING')
|
|
58
|
+
break;
|
|
59
|
+
if (Date.now() >= deadline) {
|
|
60
|
+
debug('storage entry %s not DONE after %dms, proceeding anyway', uploaded.app_url, PROCESSING_TIMEOUT_MS);
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
await new Promise((resolve) => setTimeout(resolve, PROCESSING_POLL_MS));
|
|
64
|
+
}
|
|
65
|
+
return { ...entry, app_url: entry?.app_url ?? uploaded.app_url };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=app-storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-storage.js","sourceRoot":"","sources":["../src/app-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,WAAW,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,MAAM,EAAyC,MAAM,eAAe,CAAC;AAE9E,MAAM,KAAK,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAAC;AAEhD,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACjC,MAAM,qBAAqB,GAAG,OAAO,CAAC;AAEtC;;;GAGG;AACH,MAAM,OAAO,UAAU;IACJ,GAAG,CAAgB;IACpC,wDAAwD;IACvC,OAAO,GAAG,IAAI,GAAG,EAAiC,CAAC;IAEpE,YAAY,GAAkB;QAC5B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,cAAc,CAAC,IAAY,EAAE,UAAkC;QACnE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,I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,IAAI,CAAC;gBACH,KAAK,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC3D,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAC;YAC7C,CAAC;YACD,IAAI,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,YAAY;gBAAE,MAAM;YACjD,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;gBAC3B,KAAK,CAAC,yDAAyD,EAAE,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC;gBAC1G,MAAM;YACR,CAAC;YACD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;IACnE,CAAC;CACF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AllocationCriteria } from '@mobilewright/protocol';
|
|
2
|
+
import type { AppSlot, ResolvedOptions } from './options.js';
|
|
3
|
+
export interface W3CCapabilities {
|
|
4
|
+
alwaysMatch: Record<string, unknown>;
|
|
5
|
+
firstMatch: Record<string, unknown>[];
|
|
6
|
+
}
|
|
7
|
+
/** A concrete device pinned from a catalog lookup. */
|
|
8
|
+
export interface PinnedDevice {
|
|
9
|
+
deviceName: string;
|
|
10
|
+
platformVersion: string;
|
|
11
|
+
/** True when the pin came from the physical-device catalog. */
|
|
12
|
+
real?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pick the configured app for an allocation, most-specific key first
|
|
16
|
+
* ('ios-real' beats 'ios'). Returns the raw configured value: a local path
|
|
17
|
+
* or a tb:// / https URL (the caller uploads local paths).
|
|
18
|
+
*/
|
|
19
|
+
export declare function appForCriteria(criteria: Pick<AllocationCriteria, 'platform' | 'deviceType'>, apps: Partial<Record<AppSlot, string>>): string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Build the W3C new-session payload for a set of allocation criteria.
|
|
22
|
+
* Pure — catalog lookups and app uploads happen in the caller; a pinned
|
|
23
|
+
* device (real-device allocations) overrides name/version wildcards, and
|
|
24
|
+
* `appUrl` is the already-uploaded app under test (tb:// or https).
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildCapabilities(criteria: AllocationCriteria, options: ResolvedOptions, pinned?: PinnedDevice, appUrl?: string): W3CCapabilities;
|
|
27
|
+
//# sourceMappingURL=capabilities.d.ts.map
|