@lambdatest/smartui-cli 4.1.45 → 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.
Files changed (2) hide show
  1. package/dist/index.cjs +114 -11
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -2681,7 +2681,9 @@ var env_default = () => {
2681
2681
  HTTPS_PROXY,
2682
2682
  SMARTUI_HTTP_PROXY,
2683
2683
  SMARTUI_HTTPS_PROXY,
2684
- GITHUB_ACTIONS,
2684
+ GIT_URL,
2685
+ BASIC_AUTH_USERNAME,
2686
+ BASIC_AUTH_PASSWORD,
2685
2687
  FIGMA_TOKEN,
2686
2688
  LT_USERNAME,
2687
2689
  LT_ACCESS_KEY,
@@ -2708,7 +2710,9 @@ var env_default = () => {
2708
2710
  HTTPS_PROXY,
2709
2711
  SMARTUI_HTTP_PROXY,
2710
2712
  SMARTUI_HTTPS_PROXY,
2711
- GITHUB_ACTIONS,
2713
+ GIT_URL,
2714
+ BASIC_AUTH_USERNAME,
2715
+ BASIC_AUTH_PASSWORD,
2712
2716
  FIGMA_TOKEN,
2713
2717
  LT_USERNAME,
2714
2718
  LT_ACCESS_KEY,
@@ -2725,7 +2729,8 @@ var env_default = () => {
2725
2729
  SMARTUI_SSE_URL,
2726
2730
  LT_SDK_SKIP_EXECUTION_LOGS: LT_SDK_SKIP_EXECUTION_LOGS === "true",
2727
2731
  MAX_CONCURRENT_PROCESSING: MAX_CONCURRENT_PROCESSING ? parseInt(MAX_CONCURRENT_PROCESSING, 10) : 0,
2728
- 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"
2729
2734
  };
2730
2735
  };
2731
2736
  var logContext = {};
@@ -2820,7 +2825,7 @@ var authExec_default = (ctx) => {
2820
2825
  };
2821
2826
 
2822
2827
  // package.json
2823
- var version = "4.1.45";
2828
+ var version = "4.1.46";
2824
2829
  var package_default = {
2825
2830
  name: "@lambdatest/smartui-cli",
2826
2831
  version,
@@ -3291,7 +3296,7 @@ var httpClient = class {
3291
3296
  data: requestData
3292
3297
  }, ctx.log);
3293
3298
  }
3294
- 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) {
3295
3300
  browserName = browserName === constants_default.SAFARI ? constants_default.WEBKIT : browserName;
3296
3301
  const file = fs6__default.default.readFileSync(ssPath);
3297
3302
  const form = new FormData__default.default();
@@ -3303,6 +3308,9 @@ var httpClient = class {
3303
3308
  form.append("screenshotName", ssName);
3304
3309
  form.append("baseline", baseline.toString());
3305
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
+ }
3306
3314
  return this.axiosInstance.request({
3307
3315
  url: `/screenshot`,
3308
3316
  method: "POST",
@@ -3692,6 +3700,12 @@ var ctx_default = (options) => {
3692
3700
  orientation: config.mobile.orientation || constants_default.MOBILE_ORIENTATION_PORTRAIT
3693
3701
  };
3694
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
+ }
3695
3709
  if (config.basicAuthorization) {
3696
3710
  basicAuthObj = config.basicAuthorization;
3697
3711
  }
@@ -3788,7 +3802,7 @@ var ctx_default = (options) => {
3788
3802
  fetchResultsFileName: fetchResultsFileObj,
3789
3803
  baselineBranch: options.baselineBranch || "",
3790
3804
  baselineBuild: options.baselineBuild || "",
3791
- githubURL: options.githubURL || "",
3805
+ githubURL: options.gitURL || options.githubURL || "",
3792
3806
  showRenderErrors: options.showRenderErrors ? true : false,
3793
3807
  userName: options.userName || "",
3794
3808
  accessKey: options.accessKey || ""
@@ -3860,6 +3874,9 @@ var git_default = (ctx) => {
3860
3874
  if (ctx.options.githubURL && ctx.options.githubURL.startsWith("https://")) {
3861
3875
  githubURL = ctx.options.githubURL;
3862
3876
  }
3877
+ if (ctx.options.gitURL && ctx.options.gitURL.startsWith("https://")) {
3878
+ githubURL = ctx.options.gitURL;
3879
+ }
3863
3880
  if (ctx.env.SMARTUI_GIT_INFO_FILEPATH) {
3864
3881
  let gitInfo = JSON.parse(fs6__default.default.readFileSync(ctx.env.SMARTUI_GIT_INFO_FILEPATH, "utf-8"));
3865
3882
  if (ctx.options.markBaseline) {
@@ -3871,7 +3888,7 @@ var git_default = (ctx) => {
3871
3888
  commitId: gitInfo.commit_id.slice(0, 6) || "",
3872
3889
  commitMessage: gitInfo.commit_body || "",
3873
3890
  commitAuthor: gitInfo.commit_author || "",
3874
- githubURL: githubURL ? githubURL : ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${gitInfo.commit_id}` : "",
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}`,
3875
3892
  baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ""
3876
3893
  };
3877
3894
  } else {
@@ -3891,7 +3908,7 @@ var git_default = (ctx) => {
3891
3908
  commitId: res[0] || "",
3892
3909
  commitMessage: res[2] || "",
3893
3910
  commitAuthor: res[7] || "",
3894
- githubURL: githubURL ? githubURL : ctx.env.GITHUB_ACTIONS ? `${constants_default.GITHUB_API_HOST}/repos/${process.env.GITHUB_REPOSITORY}/statuses/${res[1]}` : "",
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]}`,
3895
3912
  baselineBranch: ctx.options.baselineBranch || ctx.env.BASELINE_BRANCH || ""
3896
3913
  };
3897
3914
  }
@@ -3906,6 +3923,9 @@ function setNonGitInfo(ctx) {
3906
3923
  if (ctx.options.githubURL && ctx.options.githubURL.startsWith("https://")) {
3907
3924
  githubURL = ctx.options.githubURL;
3908
3925
  }
3926
+ if (ctx.options.gitURL && ctx.options.gitURL.startsWith("https://")) {
3927
+ githubURL = ctx.options.gitURL;
3928
+ }
3909
3929
  ctx.git = {
3910
3930
  branch,
3911
3931
  commitId: "-",
@@ -5869,6 +5889,15 @@ function captureScreenshotsForConfig(ctx, browsers, urlConfig, browserName, rend
5869
5889
  let afterNavigationScript = execute == null ? void 0 : execute.afterNavigation;
5870
5890
  let beforeSnapshotScript = execute == null ? void 0 : execute.beforeSnapshot;
5871
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;
5872
5901
  let pageOptions = { waitUntil: waitUntilEvent, timeout: ctx.config.waitForPageRender || constants_default.DEFAULT_PAGE_LOAD_TIMEOUT };
5873
5902
  ctx.log.debug(`url: ${url} pageOptions: ${JSON.stringify(pageOptions)}`);
5874
5903
  let ssId = name.toLowerCase().replace(/\s/g, "_");
@@ -5993,17 +6022,85 @@ function captureScreenshotsForConfig(ctx, browsers, urlConfig, browserName, rend
5993
6022
  if (Object.keys(headersObject).length > 0) {
5994
6023
  yield page.setExtraHTTPHeaders(headersObject);
5995
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
+ }
5996
6077
  yield page == null ? void 0 : page.goto(url.trim(), pageOptions);
5997
6078
  yield executeDocumentScripts(ctx, page, "afterNavigation", afterNavigationScript);
5998
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
+ }
5999
6086
  let ssPath = `screenshots/${ssId}/${`${browserName}-${viewport.width}x${viewport.height}`}-${ssId}.png`;
6000
6087
  yield page == null ? void 0 : page.setViewportSize({ width: viewport.width, height: viewport.height || constants_default.MIN_VIEWPORT_HEIGHT });
6001
6088
  if (fullPage)
6002
6089
  yield page == null ? void 0 : page.evaluate(scrollToBottomAndBackToTop);
6003
6090
  yield page == null ? void 0 : page.waitForTimeout(waitForTimeout || 0);
6004
6091
  yield executeDocumentScripts(ctx, page, "beforeSnapshot", beforeSnapshotScript);
6092
+ discoveryErrors.name = name;
6093
+ discoveryErrors.url = url;
6094
+ discoveryErrors.timestamp = (/* @__PURE__ */ new Date()).toISOString();
6005
6095
  yield page == null ? void 0 : page.screenshot({ path: ssPath, fullPage });
6006
- 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
+ };
6007
6104
  }
6008
6105
  } catch (error) {
6009
6106
  throw new Error(`captureScreenshotsForConfig failed for browser ${browserName}; error: ${error}`);
@@ -6173,7 +6270,13 @@ function uploadScreenshots(ctx) {
6173
6270
  viewport = `${width}x${height}`;
6174
6271
  }
6175
6272
  }
6176
- 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);
6177
6280
  ctx.log.info(`${filePath} : uploaded successfully`);
6178
6281
  noOfScreenshots++;
6179
6282
  } else {
@@ -7356,7 +7459,7 @@ var uploadPdf_default = command10;
7356
7459
 
7357
7460
  // src/commander/commander.ts
7358
7461
  var program2 = new commander.Command();
7359
- 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);
7360
7463
  var commander_default = program2;
7361
7464
  (function() {
7362
7465
  return __async(this, null, function* () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.1.45",
3
+ "version": "4.1.46",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"