@lambdatest/smartui-cli 4.0.5 → 4.0.6

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 +91 -24
  2. package/package.json +5 -5
package/dist/index.cjs CHANGED
@@ -33,8 +33,6 @@ var spawn__default = /*#__PURE__*/_interopDefault(spawn);
33
33
  var sharp__default = /*#__PURE__*/_interopDefault(sharp);
34
34
 
35
35
  var __defProp = Object.defineProperty;
36
- var __defProps = Object.defineProperties;
37
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
38
36
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
39
37
  var __hasOwnProp = Object.prototype.hasOwnProperty;
40
38
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -50,7 +48,6 @@ var __spreadValues = (a, b) => {
50
48
  }
51
49
  return a;
52
50
  };
53
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
54
51
  var __async = (__this, __arguments, generator) => {
55
52
  return new Promise((resolve, reject) => {
56
53
  var fulfilled = (value) => {
@@ -99,7 +96,8 @@ var constants_default = {
99
96
  },
100
97
  waitForTimeout: 1e3,
101
98
  enableJavaScript: false,
102
- allowedHostnames: []
99
+ allowedHostnames: [],
100
+ smartIgnore: false
103
101
  },
104
102
  DEFAULT_WEB_STATIC_CONFIG: [
105
103
  {
@@ -119,6 +117,64 @@ var constants_default = {
119
117
  EDGE: "edge",
120
118
  EDGE_CHANNEL: "msedge",
121
119
  WEBKIT: "webkit",
120
+ // discovery browser launch arguments
121
+ LAUNCH_ARGS: [
122
+ // disable the translate popup and optimization downloads
123
+ "--disable-features=Translate,OptimizationGuideModelDownloading",
124
+ // disable several subsystems which run network requests in the background
125
+ "--disable-background-networking",
126
+ // disable task throttling of timer tasks from background pages
127
+ "--disable-background-timer-throttling",
128
+ // disable backgrounding renderer processes
129
+ "--disable-renderer-backgrounding",
130
+ // disable backgrounding renderers for occluded windows (reduce nondeterminism)
131
+ "--disable-backgrounding-occluded-windows",
132
+ // disable crash reporting
133
+ "--disable-breakpad",
134
+ // disable client side phishing detection
135
+ "--disable-client-side-phishing-detection",
136
+ // disable default component extensions with background pages for performance
137
+ "--disable-component-extensions-with-background-pages",
138
+ // disable installation of default apps on first run
139
+ "--disable-default-apps",
140
+ // work-around for environments where a small /dev/shm partition causes crashes
141
+ "--disable-dev-shm-usage",
142
+ // disable extensions
143
+ "--disable-extensions",
144
+ // disable hang monitor dialogs in renderer processes
145
+ "--disable-hang-monitor",
146
+ // disable inter-process communication flooding protection for javascript
147
+ "--disable-ipc-flooding-protection",
148
+ // disable web notifications and the push API
149
+ "--disable-notifications",
150
+ // disable the prompt when a POST request causes page navigation
151
+ "--disable-prompt-on-repost",
152
+ // disable syncing browser data with google accounts
153
+ "--disable-sync",
154
+ // disable site-isolation to make network requests easier to intercept
155
+ "--disable-site-isolation-trials",
156
+ // disable the first run tasks, whether or not it's actually the first run
157
+ "--no-first-run",
158
+ // disable the sandbox for all process types that are normally sandboxed
159
+ "--no-sandbox",
160
+ // specify a consistent encryption backend across platforms
161
+ "--password-store=basic",
162
+ // use a mock keychain on Mac to prevent blocking permissions dialogs
163
+ "--use-mock-keychain",
164
+ // enable remote debugging on the first available port
165
+ "--remote-debugging-port=0",
166
+ // sets navigator.webdriver to false
167
+ "--disable-blink-features=AutomationControlled",
168
+ // disable UA-CH feature
169
+ `--disable-features=UserAgentClientHint`
170
+ ],
171
+ // discovery request headers
172
+ REQUEST_HEADERS: {
173
+ // `HeadlessChrome` is added to sec-ch-ua, `--disable-features=UserAgentClientHint` doesn't seem to work
174
+ "sec-ch-ua": '"Chromium";v="129", "Not=A?Brand";v="8"',
175
+ "sec-ch-ua-mobile": '"?0"',
176
+ "sec-ch-ua-platform": '"Windows"'
177
+ },
122
178
  // user agents
123
179
  CHROME_USER_AGENT: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.6312.107 Safari/537.3",
124
180
  FIREFOX_USER_AGENT: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:112.0) Gecko/20100101 Firefox/112.0",
@@ -444,6 +500,10 @@ var ConfigSchema = {
444
500
  type: "boolean",
445
501
  errorMessage: "Invalid config; cliEnableJavaScript must be true/false"
446
502
  },
503
+ smartIgnore: {
504
+ type: "boolean",
505
+ errorMessage: "Invalid config; smartIgnore must be true/false"
506
+ },
447
507
  scrollTime: {
448
508
  type: "number",
449
509
  minimum: 1,
@@ -722,21 +782,21 @@ var env_default = () => {
722
782
  const {
723
783
  PROJECT_TOKEN = "",
724
784
  SMARTUI_CLIENT_API_URL = "https://api.lambdatest.com/visualui/1.0",
725
- LT_SDK_DEBUG,
726
785
  SMARTUI_GIT_INFO_FILEPATH,
786
+ SMARTUI_DO_NOT_USE_CAPTURED_COOKIES,
727
787
  HTTP_PROXY,
728
788
  HTTPS_PROXY,
729
789
  GITHUB_ACTIONS,
730
790
  FIGMA_TOKEN,
731
791
  LT_USERNAME,
732
792
  LT_ACCESS_KEY,
793
+ LT_SDK_DEBUG,
733
794
  BASELINE_BRANCH,
734
795
  CURRENT_BRANCH
735
796
  } = process.env;
736
797
  return {
737
798
  PROJECT_TOKEN,
738
799
  SMARTUI_CLIENT_API_URL,
739
- LT_SDK_DEBUG,
740
800
  SMARTUI_GIT_INFO_FILEPATH,
741
801
  HTTP_PROXY,
742
802
  HTTPS_PROXY,
@@ -745,7 +805,9 @@ var env_default = () => {
745
805
  LT_USERNAME,
746
806
  LT_ACCESS_KEY,
747
807
  BASELINE_BRANCH,
748
- CURRENT_BRANCH
808
+ CURRENT_BRANCH,
809
+ LT_SDK_DEBUG: LT_SDK_DEBUG === "true",
810
+ SMARTUI_DO_NOT_USE_CAPTURED_COOKIES: SMARTUI_DO_NOT_USE_CAPTURED_COOKIES === "true"
749
811
  };
750
812
  };
751
813
  var logContext = {};
@@ -754,7 +816,7 @@ function updateLogContext(newContext) {
754
816
  }
755
817
  var logLevel = () => {
756
818
  let env = env_default();
757
- return env.LT_SDK_DEBUG === "true" ? "debug" : "info";
819
+ return env.LT_SDK_DEBUG ? "debug" : "info";
758
820
  };
759
821
  var logger = winston.createLogger({
760
822
  format: winston.format.combine(
@@ -822,7 +884,7 @@ var auth_default = (ctx) => {
822
884
  };
823
885
 
824
886
  // package.json
825
- var version = "4.0.5";
887
+ var version = "4.0.6";
826
888
  var package_default = {
827
889
  name: "@lambdatest/smartui-cli",
828
890
  version,
@@ -846,10 +908,10 @@ var package_default = {
846
908
  author: "LambdaTest <keys@lambdatest.com>",
847
909
  license: "MIT",
848
910
  dependencies: {
849
- "@playwright/browser-chromium": "^1.45.3",
850
- "@playwright/browser-firefox": "^1.45.3",
851
- "@playwright/browser-webkit": "^1.45.3",
852
- "@playwright/test": "^1.45.3",
911
+ "@playwright/browser-chromium": "^1.47.2",
912
+ "@playwright/browser-firefox": "^1.47.2",
913
+ "@playwright/browser-webkit": "^1.47.2",
914
+ "@playwright/test": "^1.47.2",
853
915
  "@types/cross-spawn": "^6.0.4",
854
916
  "@types/node": "^20.8.9",
855
917
  "@types/which": "^3.0.2",
@@ -1034,7 +1096,7 @@ var httpClient = class {
1034
1096
  }
1035
1097
  };
1036
1098
  var ctx_default = (options) => {
1037
- var _a, _b, _c;
1099
+ var _a, _b, _c, _d, _e, _f;
1038
1100
  let env = env_default();
1039
1101
  let webConfig;
1040
1102
  let mobileConfig;
@@ -1092,11 +1154,12 @@ var ctx_default = (options) => {
1092
1154
  mobile: mobileConfig,
1093
1155
  waitForPageRender: config.waitForPageRender || 0,
1094
1156
  waitForTimeout: config.waitForTimeout || 0,
1095
- enableJavaScript: config.enableJavaScript || false,
1096
- cliEnableJavaScript: config.cliEnableJavaScript || true,
1157
+ enableJavaScript: (_d = config.enableJavaScript) != null ? _d : false,
1158
+ cliEnableJavaScript: (_e = config.cliEnableJavaScript) != null ? _e : true,
1097
1159
  scrollTime: config.scrollTime || constants_default.DEFAULT_SCROLL_TIME,
1098
1160
  allowedHostnames: config.allowedHostnames || [],
1099
- basicAuthorization: basicAuthObj
1161
+ basicAuthorization: basicAuthObj,
1162
+ smartIgnore: (_f = config.smartIgnore) != null ? _f : false
1100
1163
  },
1101
1164
  uploadFilePath: "",
1102
1165
  webStaticConfig: [],
@@ -1505,7 +1568,7 @@ var Queue = class {
1505
1568
  return this.processedSnapshots;
1506
1569
  }
1507
1570
  isEmpty() {
1508
- return this.snapshots.length ? false : true;
1571
+ return this.snapshots && this.snapshots.length ? false : true;
1509
1572
  }
1510
1573
  };
1511
1574
  function processSnapshot(snapshot, ctx) {
@@ -1513,7 +1576,10 @@ function processSnapshot(snapshot, ctx) {
1513
1576
  var _a;
1514
1577
  updateLogContext({ task: "discovery" });
1515
1578
  ctx.log.debug(`Processing snapshot ${snapshot.name} ${snapshot.url}`);
1516
- let launchOptions = { headless: true };
1579
+ let launchOptions = {
1580
+ headless: true,
1581
+ args: constants_default.LAUNCH_ARGS
1582
+ };
1517
1583
  let contextOptions = {
1518
1584
  javaScriptEnabled: ctx.config.cliEnableJavaScript,
1519
1585
  userAgent: constants_default.CHROME_USER_AGENT
@@ -1526,7 +1592,7 @@ function processSnapshot(snapshot, ctx) {
1526
1592
  }
1527
1593
  const context = yield ctx.browser.newContext(contextOptions);
1528
1594
  ctx.log.debug(`Browser context created with options ${JSON.stringify(contextOptions)}`);
1529
- if (snapshot.dom.cookies) {
1595
+ if (!ctx.env.SMARTUI_DO_NOT_USE_CAPTURED_COOKIES && snapshot.dom.cookies) {
1530
1596
  const domainName = new URL(snapshot.url).hostname;
1531
1597
  ctx.log.debug(`Setting cookies for domain: ${domainName}`);
1532
1598
  const cookieArray = snapshot.dom.cookies.split("; ").map((cookie) => {
@@ -1562,7 +1628,10 @@ function processSnapshot(snapshot, ctx) {
1562
1628
  yield page.route("**/*", (route, request) => __async(this, null, function* () {
1563
1629
  const requestUrl = request.url();
1564
1630
  const requestHostname = new URL(requestUrl).hostname;
1565
- let requestOptions = { timeout: REQUEST_TIMEOUT };
1631
+ let requestOptions = {
1632
+ timeout: REQUEST_TIMEOUT,
1633
+ headers: __spreadValues(__spreadValues({}, yield request.allHeaders()), constants_default.REQUEST_HEADERS)
1634
+ };
1566
1635
  try {
1567
1636
  if (/\.(mp3|mp4|wav|ogg|webm)$/i.test(request.url())) {
1568
1637
  throw new Error("resource type mp3/mp4/wav/ogg/webm");
@@ -1573,9 +1642,7 @@ function processSnapshot(snapshot, ctx) {
1573
1642
  if (ctx.config.basicAuthorization) {
1574
1643
  ctx.log.debug(`Adding basic authorization to the headers for root url`);
1575
1644
  let token = Buffer.from(`${ctx.config.basicAuthorization.username}:${ctx.config.basicAuthorization.password}`).toString("base64");
1576
- requestOptions.headers = __spreadProps(__spreadValues({}, request.headers()), {
1577
- Authorization: `Basic ${token}`
1578
- });
1645
+ requestOptions.headers.Authorization = `Basic ${token}`;
1579
1646
  }
1580
1647
  let response, body;
1581
1648
  if (requestUrl === snapshot.url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambdatest/smartui-cli",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
4
4
  "description": "A command line interface (CLI) to run SmartUI tests on LambdaTest",
5
5
  "files": [
6
6
  "dist/**/*"
@@ -17,10 +17,10 @@
17
17
  "author": "LambdaTest <keys@lambdatest.com>",
18
18
  "license": "MIT",
19
19
  "dependencies": {
20
- "@playwright/browser-chromium": "^1.45.3",
21
- "@playwright/browser-firefox": "^1.45.3",
22
- "@playwright/browser-webkit": "^1.45.3",
23
- "@playwright/test": "^1.45.3",
20
+ "@playwright/browser-chromium": "^1.47.2",
21
+ "@playwright/browser-firefox": "^1.47.2",
22
+ "@playwright/browser-webkit": "^1.47.2",
23
+ "@playwright/test": "^1.47.2",
24
24
  "@types/cross-spawn": "^6.0.4",
25
25
  "@types/node": "^20.8.9",
26
26
  "@types/which": "^3.0.2",