wdio-lambdatest-service-sdk 5.1.2 → 5.1.4
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/README.md +20 -14
- package/bin/cli.js +2 -2
- package/bin/generate-config.js +1 -1
- package/bin/setup.js +1 -1
- package/index.js +10 -3
- package/lib/cli/generate.js +43 -29
- package/package.json +1 -1
- package/src/launcher.js +4 -5
package/README.md
CHANGED
|
@@ -26,16 +26,20 @@ WebdriverIO service and CLI for running Appium and browser tests on [LambdaTest]
|
|
|
26
26
|
- **Authentication**: Pass `username` and `accessKey` in the service options or via the CLI.
|
|
27
27
|
- **Test Status Updates**: Automatically marks tests as Passed/Failed on the LambdaTest dashboard using Lambda Hooks.
|
|
28
28
|
- **Logs**: Clean, colorful status logs in the terminal.
|
|
29
|
-
- **CLI**: Interactive config generator and setup tool (Commander, Chalk, Inquirer; runs with
|
|
29
|
+
- **CLI**: Interactive config generator and setup tool (Commander, Chalk, Inquirer; runs with Node.js or Bun).
|
|
30
30
|
- **Multi-select**: Choose multiple test types, device types, platforms, and app/website targets in one config.
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
34
|
## Installation
|
|
35
35
|
|
|
36
|
+
Works with **Node.js** (≥18) or **Bun** (≥1.0). No Bun required.
|
|
37
|
+
|
|
36
38
|
```bash
|
|
39
|
+
# With npm (Node.js)
|
|
37
40
|
npm install wdio-lambdatest-service --save-dev
|
|
38
|
-
|
|
41
|
+
|
|
42
|
+
# With Bun (optional)
|
|
39
43
|
bun add wdio-lambdatest-service --dev
|
|
40
44
|
```
|
|
41
45
|
|
|
@@ -207,11 +211,11 @@ npm install wdio-lambdatest-service --save-dev
|
|
|
207
211
|
### 2. Run the Config Generator
|
|
208
212
|
|
|
209
213
|
```bash
|
|
210
|
-
# With Bun (recommended)
|
|
211
|
-
bun wdio-lt generate
|
|
212
|
-
|
|
213
214
|
# With Node.js
|
|
214
215
|
npx wdio-lt generate
|
|
216
|
+
|
|
217
|
+
# With Bun (optional)
|
|
218
|
+
bunx wdio-lt generate
|
|
215
219
|
```
|
|
216
220
|
|
|
217
221
|
### 3. Follow the Prompts
|
|
@@ -270,19 +274,21 @@ wdio-lt setup
|
|
|
270
274
|
wdio-lt generate
|
|
271
275
|
```
|
|
272
276
|
|
|
273
|
-
### Running
|
|
277
|
+
### Running the CLI
|
|
278
|
+
|
|
279
|
+
**With Node.js** (default; no extra install):
|
|
274
280
|
|
|
275
281
|
```bash
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
bun wdio-lt generate
|
|
282
|
+
npx wdio-lt setup ./android-sample
|
|
283
|
+
npx wdio-lt generate
|
|
279
284
|
```
|
|
280
285
|
|
|
281
|
-
|
|
286
|
+
**With Bun** (optional; faster):
|
|
282
287
|
|
|
283
288
|
```bash
|
|
284
|
-
|
|
285
|
-
|
|
289
|
+
curl -fsSL https://bun.sh/install | bash # Install Bun
|
|
290
|
+
bunx wdio-lt setup ./android-sample
|
|
291
|
+
bunx wdio-lt generate
|
|
286
292
|
```
|
|
287
293
|
|
|
288
294
|
### Legacy Commands (backward compatible)
|
|
@@ -391,8 +397,8 @@ wdio-lambdatest-service/
|
|
|
391
397
|
|
|
392
398
|
### Requirements
|
|
393
399
|
|
|
394
|
-
- **Node.js**: >= 18.0.0
|
|
395
|
-
- **Bun**: >= 1.0.0 (optional
|
|
400
|
+
- **Node.js**: >= 18.0.0 (required for npm install and default CLI run)
|
|
401
|
+
- **Bun**: >= 1.0.0 (optional; use `bun add` / `bunx wdio-lt` for faster install and run)
|
|
396
402
|
|
|
397
403
|
---
|
|
398
404
|
|
package/bin/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* LambdaTest WDIO CLI - Unified command-line interface.
|
|
4
4
|
* Powered by Commander, Chalk, and Inquirer.
|
|
5
|
-
* Runs with
|
|
5
|
+
* Runs with Node.js or Bun.
|
|
6
6
|
*/
|
|
7
7
|
const { Command } = require('commander');
|
|
8
8
|
const chalk = require('chalk');
|
package/bin/generate-config.js
CHANGED
package/bin/setup.js
CHANGED
package/index.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WDIO LambdaTest service entry point.
|
|
3
3
|
* Exposes the service class and launcher for WebdriverIO.
|
|
4
|
+
* Export shape supports both CommonJS and WDIO plugin resolution (default + launcher).
|
|
4
5
|
*/
|
|
5
6
|
const LambdaTestService = require('./src/service');
|
|
6
7
|
const LambdaTestLauncher = require('./src/launcher');
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// Primary export: the worker service class (used by WDIO in worker process)
|
|
10
|
+
const Service = LambdaTestService;
|
|
11
|
+
|
|
12
|
+
// Attach launcher so WDIO can read plugin.launcher (main process)
|
|
13
|
+
Service.launcher = LambdaTestLauncher;
|
|
14
|
+
// ESM interop: some loaders expect plugin.default
|
|
15
|
+
Service.default = Service;
|
|
16
|
+
|
|
17
|
+
module.exports = Service;
|
package/lib/cli/generate.js
CHANGED
|
@@ -163,19 +163,41 @@ function buildCapabilitiesMulti(config) {
|
|
|
163
163
|
return capabilities;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Resolve LambdaTest service path: try package name first (npm install), then sibling (reference repo).
|
|
168
|
+
* Reference repo layout: LT_Test/ (configs) and wdio-lambdatest-service/ as siblings.
|
|
169
|
+
*/
|
|
170
|
+
function getServicePathSnippet() {
|
|
171
|
+
return `(function () {
|
|
172
|
+
try { return require.resolve('wdio-lambdatest-service'); } catch (e) {}
|
|
173
|
+
return path.join(__dirname, '../wdio-lambdatest-service');
|
|
174
|
+
})()`;
|
|
175
|
+
}
|
|
176
|
+
|
|
166
177
|
/**
|
|
167
178
|
* Build config file template string.
|
|
179
|
+
* Reference: LT_Test/ for configs, ../specs/ for specs, ../wdio-lambdatest-service or npm package for SDK.
|
|
168
180
|
*/
|
|
169
181
|
function buildConfigTemplate(config, commonCaps, capabilities) {
|
|
182
|
+
const servicePathExpr = getServicePathSnippet();
|
|
183
|
+
const safeSpecPath = config.specPath.replace(/\\/g, '/');
|
|
184
|
+
const mergeSnippet = capabilities.length > 0
|
|
185
|
+
? `
|
|
186
|
+
// Merge commonCapabilities into each capability
|
|
187
|
+
exports.config.capabilities.forEach(function (caps) {
|
|
188
|
+
for (const i in exports.config.commonCapabilities) {
|
|
189
|
+
caps[i] = caps[i] || exports.config.commonCapabilities[i];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
`
|
|
193
|
+
: '';
|
|
194
|
+
|
|
170
195
|
return `const path = require('path');
|
|
171
196
|
|
|
197
|
+
// LambdaTest WDIO config (generated). Layout: LT_Test/ for configs, ../specs/ for specs (see LT-appium-nodejs-webdriverio).
|
|
172
198
|
exports.config = {
|
|
173
|
-
// Authentication handled by SDK
|
|
174
|
-
// user: "${config.username}",
|
|
175
|
-
// key: "${config.key}",
|
|
176
|
-
|
|
177
199
|
updateJob: false,
|
|
178
|
-
specs: ["${
|
|
200
|
+
specs: ["${safeSpecPath}"],
|
|
179
201
|
exclude: [],
|
|
180
202
|
|
|
181
203
|
maxInstances: ${config.parallel > 0 ? config.parallel : 1},
|
|
@@ -196,9 +218,9 @@ exports.config = {
|
|
|
196
218
|
port: 80,
|
|
197
219
|
|
|
198
220
|
services: [
|
|
199
|
-
[
|
|
200
|
-
user: "${config.username}",
|
|
201
|
-
key: "${config.key}"
|
|
221
|
+
[${servicePathExpr}, {
|
|
222
|
+
user: "${(config.username || '').replace(/"/g, '\\"')}",
|
|
223
|
+
key: "${(config.key || '').replace(/"/g, '\\"')}"
|
|
202
224
|
}]
|
|
203
225
|
],
|
|
204
226
|
|
|
@@ -208,14 +230,7 @@ exports.config = {
|
|
|
208
230
|
timeout: 20000,
|
|
209
231
|
},
|
|
210
232
|
};
|
|
211
|
-
|
|
212
|
-
// Merge commonCapabilities into each capability
|
|
213
|
-
exports.config.capabilities.forEach(function (caps) {
|
|
214
|
-
for (const i in exports.config.commonCapabilities) {
|
|
215
|
-
caps[i] = caps[i] || exports.config.commonCapabilities[i];
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
`;
|
|
233
|
+
${mergeSnippet}`;
|
|
219
234
|
}
|
|
220
235
|
|
|
221
236
|
function printBanner() {
|
|
@@ -425,34 +440,33 @@ async function runGenerate() {
|
|
|
425
440
|
]);
|
|
426
441
|
config.parallel = parallelAnswer.parallel || 0;
|
|
427
442
|
|
|
428
|
-
// Spec file path
|
|
443
|
+
// Spec file path (reference repo: LT_Test and specs/ are siblings, so ../specs/ from LT_Test)
|
|
444
|
+
const defaultSpecPath = '../specs/android-test.js';
|
|
429
445
|
const specAnswer = await inquirer.default.prompt([
|
|
430
446
|
{
|
|
431
447
|
type: 'input',
|
|
432
448
|
name: 'specPath',
|
|
433
|
-
message: 'Spec file path:',
|
|
434
|
-
default:
|
|
449
|
+
message: 'Spec file path (relative to config dir, e.g. ../specs/android-test.js):',
|
|
450
|
+
default: defaultSpecPath
|
|
435
451
|
}
|
|
436
452
|
]);
|
|
437
453
|
|
|
438
|
-
let rawSpec = specAnswer.specPath.trim() ||
|
|
454
|
+
let rawSpec = specAnswer.specPath.trim() || defaultSpecPath;
|
|
439
455
|
|
|
440
|
-
//
|
|
441
|
-
|
|
442
|
-
|
|
456
|
+
// Resolve spec path relative to outputDir (LT_Test). Reference: specs/ at repo root = ../specs/ from LT_Test.
|
|
457
|
+
const fromOutputDir = path.resolve(outputDir, rawSpec);
|
|
458
|
+
if (fs.existsSync(fromOutputDir)) {
|
|
459
|
+
config.specPath = path.relative(outputDir, fromOutputDir).replace(/\\/g, '/') || rawSpec;
|
|
443
460
|
} else {
|
|
444
461
|
const rootPath = path.resolve(outputDir, '..');
|
|
445
462
|
const relativeToRoot = rawSpec.replace(/^\.\//, '');
|
|
446
463
|
const pathFromRoot = path.join(rootPath, relativeToRoot);
|
|
447
|
-
|
|
448
464
|
if (fs.existsSync(pathFromRoot)) {
|
|
449
465
|
config.specPath = path.relative(outputDir, pathFromRoot).replace(/\\/g, '/');
|
|
450
466
|
} else {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
config.specPath = rawSpec;
|
|
455
|
-
}
|
|
467
|
+
config.specPath = !path.isAbsolute(rawSpec) && !rawSpec.startsWith('../')
|
|
468
|
+
? '../' + relativeToRoot
|
|
469
|
+
: rawSpec;
|
|
456
470
|
}
|
|
457
471
|
}
|
|
458
472
|
|
package/package.json
CHANGED
package/src/launcher.js
CHANGED
|
@@ -47,22 +47,21 @@ function applyCredentialsToCapabilities(capabilities, credentials) {
|
|
|
47
47
|
module.exports = class LambdaTestLauncher {
|
|
48
48
|
constructor(serviceOptions, capabilities, config) {
|
|
49
49
|
this.options = serviceOptions || {};
|
|
50
|
-
console.log('[LambdaTest Service] Launcher initialized with options:', JSON.stringify(this.options));
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
onPrepare(config, capabilities) {
|
|
54
|
-
|
|
53
|
+
if (!config) return;
|
|
54
|
+
const capsList = Array.isArray(capabilities) ? capabilities : capabilities ? [capabilities] : [];
|
|
55
|
+
if (capsList.length === 0) return;
|
|
55
56
|
|
|
56
57
|
const credentials = resolveCredentials(this.options, config);
|
|
57
58
|
applyCredentialsToConfig(config, credentials);
|
|
58
|
-
|
|
59
|
-
const capsList = Array.isArray(capabilities) ? capabilities : [capabilities];
|
|
60
59
|
applyCredentialsToCapabilities(capsList, credentials);
|
|
61
60
|
|
|
62
61
|
if (credentials.user && credentials.key) {
|
|
63
62
|
console.log('[LambdaTest Service] Credentials injected into config and capabilities.');
|
|
64
63
|
} else {
|
|
65
|
-
console.
|
|
64
|
+
console.warn('[LambdaTest Service] Credentials not set. Use service options or LT_USERNAME / LT_ACCESS_KEY.');
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
};
|