@lambdatest/smartui-cli 4.1.44 → 4.1.46
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 +138 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2630,6 +2630,30 @@ var server_default = (ctx) => __async(void 0, null, function* () {
|
|
|
2630
2630
|
return reply.code(replyCode).send(replyBody);
|
|
2631
2631
|
}
|
|
2632
2632
|
}));
|
|
2633
|
+
server.get("/build/info", opts, (request, reply) => __async(void 0, null, function* () {
|
|
2634
|
+
let replyCode;
|
|
2635
|
+
let replyBody;
|
|
2636
|
+
try {
|
|
2637
|
+
if (ctx.build && ctx.build.id) {
|
|
2638
|
+
const buildInfo = ctx.build;
|
|
2639
|
+
const data = {
|
|
2640
|
+
buildId: buildInfo.id,
|
|
2641
|
+
buildName: buildInfo.name,
|
|
2642
|
+
baseline: buildInfo.baseline,
|
|
2643
|
+
projectToken: ctx.env.PROJECT_TOKEN || ""
|
|
2644
|
+
};
|
|
2645
|
+
replyCode = 200;
|
|
2646
|
+
replyBody = { data };
|
|
2647
|
+
} else {
|
|
2648
|
+
throw new Error("Build information is not available");
|
|
2649
|
+
}
|
|
2650
|
+
} catch (error) {
|
|
2651
|
+
ctx.log.debug(`build info failed; ${error}`);
|
|
2652
|
+
replyCode = 500;
|
|
2653
|
+
replyBody = { error: { message: error.message } };
|
|
2654
|
+
}
|
|
2655
|
+
return reply.code(replyCode).send(replyBody);
|
|
2656
|
+
}));
|
|
2633
2657
|
if (ctx.sourceCommand && ctx.sourceCommand === "exec-start") {
|
|
2634
2658
|
yield server.listen({ port: ctx.options.port });
|
|
2635
2659
|
let { port } = server.addresses()[0];
|
|
@@ -2657,7 +2681,9 @@ var env_default = () => {
|
|
|
2657
2681
|
HTTPS_PROXY,
|
|
2658
2682
|
SMARTUI_HTTP_PROXY,
|
|
2659
2683
|
SMARTUI_HTTPS_PROXY,
|
|
2660
|
-
|
|
2684
|
+
GIT_URL,
|
|
2685
|
+
BASIC_AUTH_USERNAME,
|
|
2686
|
+
BASIC_AUTH_PASSWORD,
|
|
2661
2687
|
FIGMA_TOKEN,
|
|
2662
2688
|
LT_USERNAME,
|
|
2663
2689
|
LT_ACCESS_KEY,
|
|
@@ -2684,7 +2710,9 @@ var env_default = () => {
|
|
|
2684
2710
|
HTTPS_PROXY,
|
|
2685
2711
|
SMARTUI_HTTP_PROXY,
|
|
2686
2712
|
SMARTUI_HTTPS_PROXY,
|
|
2687
|
-
|
|
2713
|
+
GIT_URL,
|
|
2714
|
+
BASIC_AUTH_USERNAME,
|
|
2715
|
+
BASIC_AUTH_PASSWORD,
|
|
2688
2716
|
FIGMA_TOKEN,
|
|
2689
2717
|
LT_USERNAME,
|
|
2690
2718
|
LT_ACCESS_KEY,
|
|
@@ -2701,7 +2729,8 @@ var env_default = () => {
|
|
|
2701
2729
|
SMARTUI_SSE_URL,
|
|
2702
2730
|
LT_SDK_SKIP_EXECUTION_LOGS: LT_SDK_SKIP_EXECUTION_LOGS === "true",
|
|
2703
2731
|
MAX_CONCURRENT_PROCESSING: MAX_CONCURRENT_PROCESSING ? parseInt(MAX_CONCURRENT_PROCESSING, 10) : 0,
|
|
2704
|
-
DO_NOT_USE_USER_AGENT: DO_NOT_USE_USER_AGENT === "true"
|
|
2732
|
+
DO_NOT_USE_USER_AGENT: DO_NOT_USE_USER_AGENT === "true",
|
|
2733
|
+
CAPTURE_RENDERING_ERRORS: process.env.CAPTURE_RENDERING_ERRORS === "true"
|
|
2705
2734
|
};
|
|
2706
2735
|
};
|
|
2707
2736
|
var logContext = {};
|
|
@@ -2796,7 +2825,7 @@ var authExec_default = (ctx) => {
|
|
|
2796
2825
|
};
|
|
2797
2826
|
|
|
2798
2827
|
// package.json
|
|
2799
|
-
var version = "4.1.
|
|
2828
|
+
var version = "4.1.46";
|
|
2800
2829
|
var package_default = {
|
|
2801
2830
|
name: "@lambdatest/smartui-cli",
|
|
2802
2831
|
version,
|
|
@@ -3267,7 +3296,7 @@ var httpClient = class {
|
|
|
3267
3296
|
data: requestData
|
|
3268
3297
|
}, ctx.log);
|
|
3269
3298
|
}
|
|
3270
|
-
uploadScreenshot({ id: buildId, name: buildName, baseline }, ssPath, ssName, browserName, viewport, url = "", log2) {
|
|
3299
|
+
uploadScreenshot({ id: buildId, name: buildName, baseline }, ssPath, ssName, browserName, viewport, url = "", log2, discoveryErrors, ctx) {
|
|
3271
3300
|
browserName = browserName === constants_default.SAFARI ? constants_default.WEBKIT : browserName;
|
|
3272
3301
|
const file = fs6__default.default.readFileSync(ssPath);
|
|
3273
3302
|
const form = new FormData__default.default();
|
|
@@ -3279,6 +3308,9 @@ var httpClient = class {
|
|
|
3279
3308
|
form.append("screenshotName", ssName);
|
|
3280
3309
|
form.append("baseline", baseline.toString());
|
|
3281
3310
|
form.append("pageUrl", url);
|
|
3311
|
+
if ((ctx == null ? void 0 : ctx.env.CAPTURE_RENDERING_ERRORS) && discoveryErrors) {
|
|
3312
|
+
form.append("discoveryErrors", JSON.stringify(discoveryErrors));
|
|
3313
|
+
}
|
|
3282
3314
|
return this.axiosInstance.request({
|
|
3283
3315
|
url: `/screenshot`,
|
|
3284
3316
|
method: "POST",
|
|
@@ -3668,6 +3700,12 @@ var ctx_default = (options) => {
|
|
|
3668
3700
|
orientation: config.mobile.orientation || constants_default.MOBILE_ORIENTATION_PORTRAIT
|
|
3669
3701
|
};
|
|
3670
3702
|
}
|
|
3703
|
+
if (env.BASIC_AUTH_USERNAME && env.BASIC_AUTH_PASSWORD) {
|
|
3704
|
+
basicAuthObj = {
|
|
3705
|
+
"username": env.BASIC_AUTH_USERNAME,
|
|
3706
|
+
"password": env.BASIC_AUTH_PASSWORD
|
|
3707
|
+
};
|
|
3708
|
+
}
|
|
3671
3709
|
if (config.basicAuthorization) {
|
|
3672
3710
|
basicAuthObj = config.basicAuthorization;
|
|
3673
3711
|
}
|
|
@@ -3764,7 +3802,7 @@ var ctx_default = (options) => {
|
|
|
3764
3802
|
fetchResultsFileName: fetchResultsFileObj,
|
|
3765
3803
|
baselineBranch: options.baselineBranch || "",
|
|
3766
3804
|
baselineBuild: options.baselineBuild || "",
|
|
3767
|
-
githubURL: options.githubURL || "",
|
|
3805
|
+
githubURL: options.gitURL || options.githubURL || "",
|
|
3768
3806
|
showRenderErrors: options.showRenderErrors ? true : false,
|
|
3769
3807
|
userName: options.userName || "",
|
|
3770
3808
|
accessKey: options.accessKey || ""
|
|
@@ -3836,6 +3874,9 @@ var git_default = (ctx) => {
|
|
|
3836
3874
|
if (ctx.options.githubURL && ctx.options.githubURL.startsWith("https://")) {
|
|
3837
3875
|
githubURL = ctx.options.githubURL;
|
|
3838
3876
|
}
|
|
3877
|
+
if (ctx.options.gitURL && ctx.options.gitURL.startsWith("https://")) {
|
|
3878
|
+
githubURL = ctx.options.gitURL;
|
|
3879
|
+
}
|
|
3839
3880
|
if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
|
|
3840
3881
|
let gitInfo = JSON.parse(fs6__default.default.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, "utf-8"));
|
|
3841
3882
|
if (ctx.options.markBaseline) {
|
|
@@ -3847,7 +3888,7 @@ var git_default = (ctx) => {
|
|
|
3847
3888
|
commitId: gitInfo.commit_id.slice(0, 6) || "",
|
|
3848
3889
|
commitMessage: gitInfo.commit_body || "",
|
|
3849
3890
|
commitAuthor: gitInfo.commit_author || "",
|
|
3850
|
-
githubURL: githubURL ? githubURL : ctx.env.
|
|
3891
|
+
githubURL: githubURL ? githubURL : ctx.env.GIT_URL ? ctx.env.GIT_URL : `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}`,
|
|
3851
3892
|
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ""
|
|
3852
3893
|
};
|
|
3853
3894
|
} else {
|
|
@@ -3867,7 +3908,7 @@ var git_default = (ctx) => {
|
|
|
3867
3908
|
commitId: res[0] || "",
|
|
3868
3909
|
commitMessage: res[2] || "",
|
|
3869
3910
|
commitAuthor: res[7] || "",
|
|
3870
|
-
githubURL: githubURL ? githubURL : ctx.env.
|
|
3911
|
+
githubURL: githubURL ? githubURL : ctx.env.GIT_URL ? ctx.env.GIT_URL : `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}`,
|
|
3871
3912
|
baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ""
|
|
3872
3913
|
};
|
|
3873
3914
|
}
|
|
@@ -3882,6 +3923,9 @@ function setNonGitInfo(ctx) {
|
|
|
3882
3923
|
if (ctx.options.githubURL && ctx.options.githubURL.startsWith("https://")) {
|
|
3883
3924
|
githubURL = ctx.options.githubURL;
|
|
3884
3925
|
}
|
|
3926
|
+
if (ctx.options.gitURL && ctx.options.gitURL.startsWith("https://")) {
|
|
3927
|
+
githubURL = ctx.options.gitURL;
|
|
3928
|
+
}
|
|
3885
3929
|
ctx.git = {
|
|
3886
3930
|
branch,
|
|
3887
3931
|
commitId: "-",
|
|
@@ -5845,6 +5889,15 @@ function captureScreenshotsForConfig(ctx, browsers, urlConfig, browserName, rend
|
|
|
5845
5889
|
let afterNavigationScript = execute == null ? void 0 : execute.afterNavigation;
|
|
5846
5890
|
let beforeSnapshotScript = execute == null ? void 0 : execute.beforeSnapshot;
|
|
5847
5891
|
let waitUntilEvent = pageEvent || process.env.SMARTUI_PAGE_WAIT_UNTIL_EVENT || "load";
|
|
5892
|
+
let discoveryErrors = {
|
|
5893
|
+
name: "",
|
|
5894
|
+
url: "",
|
|
5895
|
+
timestamp: "",
|
|
5896
|
+
snapshotUUID: "",
|
|
5897
|
+
browsers: {}
|
|
5898
|
+
};
|
|
5899
|
+
let globalViewport = "";
|
|
5900
|
+
let globalBrowser = constants_default.CHROME;
|
|
5848
5901
|
let pageOptions = { waitUntil: waitUntilEvent, timeout: ctx.config.waitForPageRender || constants_default.DEFAULT_PAGE_LOAD_TIMEOUT };
|
|
5849
5902
|
ctx.log.debug(`url: ${url} pageOptions: ${JSON.stringify(pageOptions)}`);
|
|
5850
5903
|
let ssId = name.toLowerCase().replace(/\s/g, "_");
|
|
@@ -5969,17 +6022,85 @@ function captureScreenshotsForConfig(ctx, browsers, urlConfig, browserName, rend
|
|
|
5969
6022
|
if (Object.keys(headersObject).length > 0) {
|
|
5970
6023
|
yield page.setExtraHTTPHeaders(headersObject);
|
|
5971
6024
|
}
|
|
6025
|
+
if (ctx.env.CAPTURE_RENDERING_ERRORS) {
|
|
6026
|
+
yield page.route("**/*", (route, request) => __async(this, null, function* () {
|
|
6027
|
+
var _a;
|
|
6028
|
+
const requestUrl = request.url();
|
|
6029
|
+
const requestHostname = new URL(requestUrl).hostname;
|
|
6030
|
+
let requestOptions = {
|
|
6031
|
+
timeout: 3e4,
|
|
6032
|
+
headers: __spreadValues(__spreadValues({}, yield request.allHeaders()), constants_default.REQUEST_HEADERS)
|
|
6033
|
+
};
|
|
6034
|
+
try {
|
|
6035
|
+
let response, body;
|
|
6036
|
+
response = yield page.request.fetch(request, requestOptions);
|
|
6037
|
+
body = yield response.body();
|
|
6038
|
+
let data = {
|
|
6039
|
+
statusCode: `${response.status()}`,
|
|
6040
|
+
url: requestUrl
|
|
6041
|
+
};
|
|
6042
|
+
if (response.status() >= 400 && response.status() < 600 && response.status() !== 0) {
|
|
6043
|
+
if (!discoveryErrors.browsers[globalBrowser]) {
|
|
6044
|
+
discoveryErrors.browsers[globalBrowser] = {};
|
|
6045
|
+
}
|
|
6046
|
+
if (discoveryErrors.browsers[globalBrowser] && !discoveryErrors.browsers[globalBrowser][globalViewport]) {
|
|
6047
|
+
discoveryErrors.browsers[globalBrowser][globalViewport] = [];
|
|
6048
|
+
}
|
|
6049
|
+
if (discoveryErrors.browsers[globalBrowser]) {
|
|
6050
|
+
(_a = discoveryErrors.browsers[globalBrowser][globalViewport]) == null ? void 0 : _a.push(data);
|
|
6051
|
+
}
|
|
6052
|
+
ctx.build.hasDiscoveryError = true;
|
|
6053
|
+
}
|
|
6054
|
+
route.fulfill({
|
|
6055
|
+
status: response.status(),
|
|
6056
|
+
headers: response.headers(),
|
|
6057
|
+
body
|
|
6058
|
+
});
|
|
6059
|
+
} catch (error) {
|
|
6060
|
+
ctx.log.debug(`Handling request ${requestUrl}
|
|
6061
|
+
- aborted due to ${error.message}`);
|
|
6062
|
+
route.abort();
|
|
6063
|
+
}
|
|
6064
|
+
}));
|
|
6065
|
+
}
|
|
6066
|
+
if (renderViewports && renderViewports.length > 0) {
|
|
6067
|
+
const first = renderViewports[0];
|
|
6068
|
+
globalViewport = first.viewportString;
|
|
6069
|
+
globalBrowser = browserName;
|
|
6070
|
+
if (globalViewport.toLowerCase().includes("iphone") || globalViewport.toLowerCase().includes("ipad")) {
|
|
6071
|
+
globalBrowser = constants_default.WEBKIT;
|
|
6072
|
+
}
|
|
6073
|
+
}
|
|
6074
|
+
if (browserName == constants_default.SAFARI || (globalViewport.toLowerCase().includes("iphone") || globalViewport.toLowerCase().includes("ipad"))) {
|
|
6075
|
+
globalBrowser = constants_default.WEBKIT;
|
|
6076
|
+
}
|
|
5972
6077
|
yield page == null ? void 0 : page.goto(url.trim(), pageOptions);
|
|
5973
6078
|
yield executeDocumentScripts(ctx, page, "afterNavigation", afterNavigationScript);
|
|
5974
6079
|
for (let { viewport, viewportString, fullPage } of renderViewports) {
|
|
6080
|
+
globalViewport = viewportString;
|
|
6081
|
+
globalBrowser = browserName;
|
|
6082
|
+
ctx.log.debug(`globalViewport : ${globalViewport}`);
|
|
6083
|
+
if (browserName == constants_default.SAFARI || (globalViewport.toLowerCase().includes("iphone") || globalViewport.toLowerCase().includes("ipad"))) {
|
|
6084
|
+
globalBrowser = constants_default.WEBKIT;
|
|
6085
|
+
}
|
|
5975
6086
|
let ssPath = `screenshots/${ssId}/${`${browserName}-${viewport.width}x${viewport.height}`}-${ssId}.png`;
|
|
5976
6087
|
yield page == null ? void 0 : page.setViewportSize({ width: viewport.width, height: viewport.height || constants_default.MIN_VIEWPORT_HEIGHT });
|
|
5977
6088
|
if (fullPage)
|
|
5978
6089
|
yield page == null ? void 0 : page.evaluate(scrollToBottomAndBackToTop);
|
|
5979
6090
|
yield page == null ? void 0 : page.waitForTimeout(waitForTimeout || 0);
|
|
5980
6091
|
yield executeDocumentScripts(ctx, page, "beforeSnapshot", beforeSnapshotScript);
|
|
6092
|
+
discoveryErrors.name = name;
|
|
6093
|
+
discoveryErrors.url = url;
|
|
6094
|
+
discoveryErrors.timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
5981
6095
|
yield page == null ? void 0 : page.screenshot({ path: ssPath, fullPage });
|
|
5982
|
-
yield ctx.client.uploadScreenshot(ctx.build, ssPath, name, browserName, viewportString, url, ctx.log);
|
|
6096
|
+
yield ctx.client.uploadScreenshot(ctx.build, ssPath, name, browserName, viewportString, url, ctx.log, discoveryErrors, ctx);
|
|
6097
|
+
discoveryErrors = {
|
|
6098
|
+
name: "",
|
|
6099
|
+
url: "",
|
|
6100
|
+
timestamp: "",
|
|
6101
|
+
snapshotUUID: "",
|
|
6102
|
+
browsers: {}
|
|
6103
|
+
};
|
|
5983
6104
|
}
|
|
5984
6105
|
} catch (error) {
|
|
5985
6106
|
throw new Error(`captureScreenshotsForConfig failed for browser ${browserName}; error: ${error}`);
|
|
@@ -6149,7 +6270,13 @@ function uploadScreenshots(ctx) {
|
|
|
6149
6270
|
viewport = `${width}x${height}`;
|
|
6150
6271
|
}
|
|
6151
6272
|
}
|
|
6152
|
-
yield ctx.client.uploadScreenshot(ctx.build, filePath, ssId, "default", viewport, "", ctx.log
|
|
6273
|
+
yield ctx.client.uploadScreenshot(ctx.build, filePath, ssId, "default", viewport, "", ctx.log, {
|
|
6274
|
+
name: "",
|
|
6275
|
+
url: "",
|
|
6276
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6277
|
+
snapshotUUID: "",
|
|
6278
|
+
browsers: {}
|
|
6279
|
+
}, ctx);
|
|
6153
6280
|
ctx.log.info(`${filePath} : uploaded successfully`);
|
|
6154
6281
|
noOfScreenshots++;
|
|
6155
6282
|
} else {
|
|
@@ -7332,7 +7459,7 @@ var uploadPdf_default = command10;
|
|
|
7332
7459
|
|
|
7333
7460
|
// src/commander/commander.ts
|
|
7334
7461
|
var program2 = new commander.Command();
|
|
7335
|
-
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").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").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).addCommand(pingTest_default).addCommand(uploadPdf_default);
|
|
7462
|
+
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").option("--gitURL <string>", "Git URL including commitId").option("--userName <string>", "Specify the LT username").option("--accessKey <string>", "Specify the LT accesskey").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).addCommand(pingTest_default).addCommand(uploadPdf_default);
|
|
7336
7463
|
var commander_default = program2;
|
|
7337
7464
|
(function() {
|
|
7338
7465
|
return __async(this, null, function* () {
|