@lambdatest/smartui-cli 4.1.14 → 4.1.16
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/dist/index.cjs +61 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -737,6 +737,18 @@ var ConfigSchema = {
|
|
|
737
737
|
userAgent: {
|
|
738
738
|
type: "string",
|
|
739
739
|
errorMessage: "User Agent value must be a valid string"
|
|
740
|
+
},
|
|
741
|
+
requestHeaders: {
|
|
742
|
+
type: "array",
|
|
743
|
+
items: {
|
|
744
|
+
type: "object",
|
|
745
|
+
minProperties: 1,
|
|
746
|
+
additionalProperties: { type: "string" }
|
|
747
|
+
},
|
|
748
|
+
uniqueItems: true,
|
|
749
|
+
errorMessage: {
|
|
750
|
+
uniqueItems: "Invalid config; duplicates in requestHeaders"
|
|
751
|
+
}
|
|
740
752
|
}
|
|
741
753
|
},
|
|
742
754
|
anyOf: [
|
|
@@ -1655,6 +1667,9 @@ var server_default = (ctx) => __async(void 0, null, function* () {
|
|
|
1655
1667
|
console.log(`Failed to fetch capabilities for sessionId ${sessionId}: ${error.message}`);
|
|
1656
1668
|
}
|
|
1657
1669
|
}
|
|
1670
|
+
if (capsBuildId && capsBuildId !== "") {
|
|
1671
|
+
process.env.SMARTUI_BUILD_ID = capsBuildId;
|
|
1672
|
+
}
|
|
1658
1673
|
}
|
|
1659
1674
|
ctx.testType = testType;
|
|
1660
1675
|
(_c = ctx.snapshotQueue) == null ? void 0 : _c.enqueue(snapshot);
|
|
@@ -1856,7 +1871,7 @@ var authExec_default = (ctx) => {
|
|
|
1856
1871
|
};
|
|
1857
1872
|
|
|
1858
1873
|
// package.json
|
|
1859
|
-
var version = "4.1.
|
|
1874
|
+
var version = "4.1.16";
|
|
1860
1875
|
var package_default = {
|
|
1861
1876
|
name: "@lambdatest/smartui-cli",
|
|
1862
1877
|
version,
|
|
@@ -2451,7 +2466,6 @@ var ctx_default = (options) => {
|
|
|
2451
2466
|
try {
|
|
2452
2467
|
if (options.config) {
|
|
2453
2468
|
config = JSON.parse(fs5__default.default.readFileSync(options.config, "utf-8"));
|
|
2454
|
-
logger_default.debug(`Config file ${options.config} loaded: ${JSON.stringify(config, null, 2)}`);
|
|
2455
2469
|
if ((_a = config.web) == null ? void 0 : _a.resolutions) {
|
|
2456
2470
|
config.web.viewports = config.web.resolutions;
|
|
2457
2471
|
delete config.web.resolutions;
|
|
@@ -2531,7 +2545,8 @@ var ctx_default = (options) => {
|
|
|
2531
2545
|
ignoreHTTPSErrors: (_i = config.ignoreHTTPSErrors) != null ? _i : false,
|
|
2532
2546
|
skipBuildCreation: (_j = config.skipBuildCreation) != null ? _j : false,
|
|
2533
2547
|
tunnel: tunnelObj,
|
|
2534
|
-
userAgent: config.userAgent || ""
|
|
2548
|
+
userAgent: config.userAgent || "",
|
|
2549
|
+
requestHeaders: config.requestHeaders || {}
|
|
2535
2550
|
},
|
|
2536
2551
|
uploadFilePath: "",
|
|
2537
2552
|
webStaticConfig: [],
|
|
@@ -2567,7 +2582,8 @@ var ctx_default = (options) => {
|
|
|
2567
2582
|
fetchResults: fetchResultObj,
|
|
2568
2583
|
fetchResultsFileName: fetchResultsFileObj,
|
|
2569
2584
|
baselineBranch: options.baselineBranch || "",
|
|
2570
|
-
baselineBuild: options.baselineBuild || ""
|
|
2585
|
+
baselineBuild: options.baselineBuild || "",
|
|
2586
|
+
githubURL: options.githubURL || ""
|
|
2571
2587
|
},
|
|
2572
2588
|
cliVersion: version,
|
|
2573
2589
|
totalSnapshots: -1,
|
|
@@ -2615,6 +2631,10 @@ var git_default = (ctx) => {
|
|
|
2615
2631
|
ctx.env.SMART_GIT = false;
|
|
2616
2632
|
}
|
|
2617
2633
|
}
|
|
2634
|
+
let githubURL;
|
|
2635
|
+
if (ctx.options.githubURL && ctx.options.githubURL.startsWith("https://")) {
|
|
2636
|
+
githubURL = ctx.options.githubURL;
|
|
2637
|
+
}
|
|
2618
2638
|
if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
|
|
2619
2639
|
let gitInfo = JSON.parse(fs5__default.default.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, "utf-8"));
|
|
2620
2640
|
if (ctx.options.markBaseline) {
|
|
@@ -2626,7 +2646,7 @@ var git_default = (ctx) => {
|
|
|
2626
2646
|
commitId: gitInfo.commit_id.slice(0, 6) || "",
|
|
2627
2647
|
commitMessage: gitInfo.commit_body || "",
|
|
2628
2648
|
commitAuthor: gitInfo.commit_author || "",
|
|
2629
|
-
githubURL: ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : "",
|
|
2649
|
+
githubURL: githubURL ? githubURL : ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : "",
|
|
2630
2650
|
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ""
|
|
2631
2651
|
};
|
|
2632
2652
|
} else {
|
|
@@ -2646,7 +2666,7 @@ var git_default = (ctx) => {
|
|
|
2646
2666
|
commitId: res[0] || "",
|
|
2647
2667
|
commitMessage: res[2] || "",
|
|
2648
2668
|
commitAuthor: res[7] || "",
|
|
2649
|
-
githubURL: ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : "",
|
|
2669
|
+
githubURL: githubURL ? githubURL : ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : "",
|
|
2650
2670
|
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ""
|
|
2651
2671
|
};
|
|
2652
2672
|
}
|
|
@@ -2664,6 +2684,9 @@ var getGitInfo_default = (ctx) => {
|
|
|
2664
2684
|
try {
|
|
2665
2685
|
ctx2.git = git_default(ctx2);
|
|
2666
2686
|
task.output = chalk__default.default.gray(`branch: ${ctx2.git.branch}, commit: ${ctx2.git.commitId}, author: ${ctx2.git.commitAuthor}`);
|
|
2687
|
+
if (ctx2.git.githubURL && ctx2.git.githubURL !== "") {
|
|
2688
|
+
task.output += chalk__default.default.gray(`, githubURL: ${ctx2.git.githubURL}`);
|
|
2689
|
+
}
|
|
2667
2690
|
task.title = "Fetched git information";
|
|
2668
2691
|
} catch (error) {
|
|
2669
2692
|
ctx2.log.debug(error);
|
|
@@ -2691,6 +2714,8 @@ var createBuildExec_default = (ctx) => {
|
|
|
2691
2714
|
baseline: resp.data.baseline,
|
|
2692
2715
|
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
2693
2716
|
};
|
|
2717
|
+
process.env.SMARTUI_BUILD_ID = resp.data.buildId;
|
|
2718
|
+
process.env.SMARTUI_BUILD_NAME = resp.data.buildName;
|
|
2694
2719
|
} else if (resp && resp.error) {
|
|
2695
2720
|
if (resp.error.message) {
|
|
2696
2721
|
ctx2.log.error(`Error while creation of build: ${resp.error.message}`);
|
|
@@ -2779,6 +2804,10 @@ var exec_default = (ctx) => {
|
|
|
2779
2804
|
var _a3;
|
|
2780
2805
|
if (code !== null) {
|
|
2781
2806
|
task.title = `Execution of '${(_a3 = ctx2.args.execCommand) == null ? void 0 : _a3.join(" ")}' completed; exited with code ${code}`;
|
|
2807
|
+
if (code !== 0) {
|
|
2808
|
+
reject();
|
|
2809
|
+
process.exitCode = code;
|
|
2810
|
+
}
|
|
2782
2811
|
} else if (signal !== null) {
|
|
2783
2812
|
throw new Error(`Child process killed with signal ${signal}`);
|
|
2784
2813
|
}
|
|
@@ -2814,11 +2843,12 @@ var processSnapshot_default = (ctx) => {
|
|
|
2814
2843
|
});
|
|
2815
2844
|
let output = "";
|
|
2816
2845
|
for (let snapshot of (_b = ctx2.snapshotQueue) == null ? void 0 : _b.getProcessedSnapshots()) {
|
|
2817
|
-
if (snapshot.error)
|
|
2846
|
+
if (snapshot.error) {
|
|
2818
2847
|
output += `${chalk__default.default.red("\u2717")} ${chalk__default.default.gray(`${snapshot.name}
|
|
2819
2848
|
[error] ${snapshot.error}`)}
|
|
2820
2849
|
`;
|
|
2821
|
-
|
|
2850
|
+
process.exitCode = 1;
|
|
2851
|
+
} else
|
|
2822
2852
|
output += `${chalk__default.default.green("\u2713")} ${chalk__default.default.gray(snapshot.name)}
|
|
2823
2853
|
${snapshot.warnings.length ? chalk__default.default.gray(`[warning] ${snapshot.warnings.join("\n[warning] ")}
|
|
2824
2854
|
`) : ""}`;
|
|
@@ -2828,6 +2858,7 @@ ${snapshot.warnings.length ? chalk__default.default.gray(`[warning] ${snapshot.w
|
|
|
2828
2858
|
} catch (error) {
|
|
2829
2859
|
ctx2.log.debug(error);
|
|
2830
2860
|
task.output = chalk__default.default.gray(error.message);
|
|
2861
|
+
process.exitCode = 1;
|
|
2831
2862
|
throw new Error("Processing of snapshots failed");
|
|
2832
2863
|
}
|
|
2833
2864
|
}),
|
|
@@ -2923,6 +2954,9 @@ function prepareSnapshot(snapshot, ctx) {
|
|
|
2923
2954
|
if (ctx.config.basicAuthorization) {
|
|
2924
2955
|
processedOptions.basicAuthorization = ctx.config.basicAuthorization;
|
|
2925
2956
|
}
|
|
2957
|
+
if (ctx.config.requestHeaders && Array.isArray(ctx.config.requestHeaders)) {
|
|
2958
|
+
processedOptions.requestHeaders = ctx.config.requestHeaders;
|
|
2959
|
+
}
|
|
2926
2960
|
ctx.config.allowedHostnames.push(new URL(snapshot.url).hostname);
|
|
2927
2961
|
processedOptions.allowedHostnames = ctx.config.allowedHostnames;
|
|
2928
2962
|
processedOptions.skipCapturedCookies = ctx.env.SMARTUI_DO_NOT_USE_CAPTURED_COOKIES;
|
|
@@ -3068,6 +3102,9 @@ function processSnapshot(snapshot, ctx) {
|
|
|
3068
3102
|
browsers: {}
|
|
3069
3103
|
};
|
|
3070
3104
|
let processedOptions = {};
|
|
3105
|
+
if (ctx.config.requestHeaders && Array.isArray(ctx.config.requestHeaders)) {
|
|
3106
|
+
processedOptions.requestHeaders = ctx.config.requestHeaders;
|
|
3107
|
+
}
|
|
3071
3108
|
let globalViewport = "";
|
|
3072
3109
|
let globalBrowser = constants_default.CHROME;
|
|
3073
3110
|
let launchOptions = {
|
|
@@ -3142,6 +3179,13 @@ function processSnapshot(snapshot, ctx) {
|
|
|
3142
3179
|
let token = Buffer.from(`${ctx.config.basicAuthorization.username}:${ctx.config.basicAuthorization.password}`).toString("base64");
|
|
3143
3180
|
requestOptions.headers.Authorization = `Basic ${token}`;
|
|
3144
3181
|
}
|
|
3182
|
+
if (ctx.config.requestHeaders && Array.isArray(ctx.config.requestHeaders)) {
|
|
3183
|
+
ctx.config.requestHeaders.forEach((headerObj) => {
|
|
3184
|
+
Object.entries(headerObj).forEach(([key, value]) => {
|
|
3185
|
+
requestOptions.headers[key] = value;
|
|
3186
|
+
});
|
|
3187
|
+
});
|
|
3188
|
+
}
|
|
3145
3189
|
let response, body;
|
|
3146
3190
|
if (requestUrl === snapshot.url) {
|
|
3147
3191
|
response = {
|
|
@@ -3981,6 +4025,7 @@ command.name("exec").description("Run test commands around SmartUI").argument("<
|
|
|
3981
4025
|
yield tasks.run(ctx);
|
|
3982
4026
|
} catch (error) {
|
|
3983
4027
|
ctx.log.info("\nRefer docs: https://www.lambdatest.com/support/docs/smart-visual-regression-testing/");
|
|
4028
|
+
process.exitCode = 1;
|
|
3984
4029
|
throw new Error();
|
|
3985
4030
|
}
|
|
3986
4031
|
});
|
|
@@ -4178,6 +4223,8 @@ var createBuild_default = (ctx) => {
|
|
|
4178
4223
|
baseline: resp.data.baseline,
|
|
4179
4224
|
useKafkaFlow: resp.data.useKafkaFlow || false
|
|
4180
4225
|
};
|
|
4226
|
+
process.env.SMARTUI_BUILD_ID = resp.data.buildId;
|
|
4227
|
+
process.env.SMARTUI_BUILD_NAME = resp.data.buildName;
|
|
4181
4228
|
} else if (resp && resp.error) {
|
|
4182
4229
|
if (resp.error.message) {
|
|
4183
4230
|
ctx2.log.error(`Error while creation of build: ${resp.error.message}`);
|
|
@@ -4620,6 +4667,7 @@ command2.name("capture").description("Capture screenshots of static sites").argu
|
|
|
4620
4667
|
yield tasks.run(ctx);
|
|
4621
4668
|
} catch (error) {
|
|
4622
4669
|
console.log("\nRefer docs: https://www.lambdatest.com/support/docs/smart-visual-regression-testing/");
|
|
4670
|
+
process.exitCode = 1;
|
|
4623
4671
|
}
|
|
4624
4672
|
});
|
|
4625
4673
|
});
|
|
@@ -4694,6 +4742,7 @@ command3.name("upload").description("Upload screenshots from given directory").a
|
|
|
4694
4742
|
yield tasks.run(ctx);
|
|
4695
4743
|
} catch (error) {
|
|
4696
4744
|
console.log("\nRefer docs: https://www.lambdatest.com/support/docs/smart-visual-regression-testing/");
|
|
4745
|
+
process.exitCode = 1;
|
|
4697
4746
|
}
|
|
4698
4747
|
});
|
|
4699
4748
|
});
|
|
@@ -5004,6 +5053,7 @@ uploadWebFigmaCommand.name("upload-figma-web").description("Capture figma screen
|
|
|
5004
5053
|
verifyFigmaWebConfig(ctx);
|
|
5005
5054
|
} catch (error) {
|
|
5006
5055
|
ctx.log.error(chalk__default.default.red(`Invalid figma-web config; ${error.message}`));
|
|
5056
|
+
process.exitCode = 1;
|
|
5007
5057
|
return;
|
|
5008
5058
|
}
|
|
5009
5059
|
let tasks = new listr2.Listr(
|
|
@@ -5056,6 +5106,7 @@ uploadAppFigmaCommand.name("upload-figma-app").description("Capture figma screen
|
|
|
5056
5106
|
verifyFigmaWebConfig(ctx);
|
|
5057
5107
|
} catch (error) {
|
|
5058
5108
|
ctx.log.error(chalk__default.default.red(`Invalid figma-app config; ${error.message}`));
|
|
5109
|
+
process.exitCode = 1;
|
|
5059
5110
|
return;
|
|
5060
5111
|
}
|
|
5061
5112
|
let tasks = new listr2.Listr(
|
|
@@ -5399,6 +5450,7 @@ command8.name("build").description("Merge a source build into the target build")
|
|
|
5399
5450
|
yield tasks.run(ctx);
|
|
5400
5451
|
} catch (error) {
|
|
5401
5452
|
console.error("Error during merge operation:", error);
|
|
5453
|
+
process.exitCode = 1;
|
|
5402
5454
|
}
|
|
5403
5455
|
});
|
|
5404
5456
|
});
|
|
@@ -5411,7 +5463,7 @@ var merge_default = program;
|
|
|
5411
5463
|
|
|
5412
5464
|
// src/commander/commander.ts
|
|
5413
5465
|
var program2 = new commander.Command();
|
|
5414
|
-
program2.name("smartui").description("CLI to help you run your SmartUI tests on LambdaTest platform").version(`v${version}`).option("-c --config <filepath>", "Config file path").option("--markBaseline", "Mark this build baseline").option("--baselineBranch <string>", "Mark this build baseline").option("--baselineBuild <string>", "Mark this build baseline").addCommand(exec_default2).addCommand(capture_default).addCommand(configWeb).addCommand(configStatic).addCommand(upload_default).addCommand(server_default2).addCommand(stopServer_default).addCommand(merge_default).addCommand(ping_default).addCommand(configFigma).addCommand(uploadFigma).addCommand(configWebFigma).addCommand(configAppFigma).addCommand(uploadWebFigmaCommand).addCommand(uploadAppFigmaCommand);
|
|
5466
|
+
program2.name("smartui").description("CLI to help you run your SmartUI tests on LambdaTest platform").version(`v${version}`).option("-c --config <filepath>", "Config file path").option("--markBaseline", "Mark this build baseline").option("--baselineBranch <string>", "Mark this build baseline").option("--baselineBuild <string>", "Mark this build baseline").option("--githubURL <string>", "GitHub URL including commitId").addCommand(exec_default2).addCommand(capture_default).addCommand(configWeb).addCommand(configStatic).addCommand(upload_default).addCommand(server_default2).addCommand(stopServer_default).addCommand(merge_default).addCommand(ping_default).addCommand(configFigma).addCommand(uploadFigma).addCommand(configWebFigma).addCommand(configAppFigma).addCommand(uploadWebFigmaCommand).addCommand(uploadAppFigmaCommand);
|
|
5415
5467
|
var commander_default = program2;
|
|
5416
5468
|
(function() {
|
|
5417
5469
|
return __async(this, null, function* () {
|