@lambdatest/smartui-cli 4.0.0 → 4.0.1
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 +33 -12
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -135,6 +135,8 @@ var constants_default = {
|
|
|
135
135
|
// Disallowed file extension
|
|
136
136
|
FILE_EXTENSION_ZIP: ".zip",
|
|
137
137
|
FILE_EXTENSION_GIFS: "gif",
|
|
138
|
+
// Default scrollTime
|
|
139
|
+
DEFAULT_SCROLL_TIME: 8,
|
|
138
140
|
// Magic Numbers
|
|
139
141
|
MAGIC_NUMBERS: [
|
|
140
142
|
{ ext: "jpg", magic: Buffer.from([255, 216, 255]) },
|
|
@@ -435,6 +437,16 @@ var ConfigSchema = {
|
|
|
435
437
|
type: "boolean",
|
|
436
438
|
errorMessage: "Invalid config; enableJavaScript must be true/false"
|
|
437
439
|
},
|
|
440
|
+
cliEnableJavaScript: {
|
|
441
|
+
type: "boolean",
|
|
442
|
+
errorMessage: "Invalid config; cliEnableJavaScript must be true/false"
|
|
443
|
+
},
|
|
444
|
+
scrollTime: {
|
|
445
|
+
type: "number",
|
|
446
|
+
minimum: 1,
|
|
447
|
+
maximum: 1e3,
|
|
448
|
+
errorMessage: "Invalid config; scrollTime must be > 1 and <= 1000"
|
|
449
|
+
},
|
|
438
450
|
allowedHostnames: {
|
|
439
451
|
type: "array",
|
|
440
452
|
items: {
|
|
@@ -794,7 +806,7 @@ var auth_default = (ctx) => {
|
|
|
794
806
|
};
|
|
795
807
|
|
|
796
808
|
// package.json
|
|
797
|
-
var version = "4.0.
|
|
809
|
+
var version = "4.0.1";
|
|
798
810
|
var package_default = {
|
|
799
811
|
name: "@lambdatest/smartui-cli",
|
|
800
812
|
version,
|
|
@@ -818,10 +830,10 @@ var package_default = {
|
|
|
818
830
|
author: "LambdaTest <keys@lambdatest.com>",
|
|
819
831
|
license: "MIT",
|
|
820
832
|
dependencies: {
|
|
821
|
-
"@playwright/browser-chromium": "^1.
|
|
822
|
-
"@playwright/browser-firefox": "^1.
|
|
823
|
-
"@playwright/browser-webkit": "^1.
|
|
824
|
-
"@playwright/test": "^1.
|
|
833
|
+
"@playwright/browser-chromium": "^1.45.3",
|
|
834
|
+
"@playwright/browser-firefox": "^1.45.3",
|
|
835
|
+
"@playwright/browser-webkit": "^1.45.3",
|
|
836
|
+
"@playwright/test": "^1.45.3",
|
|
825
837
|
"@types/cross-spawn": "^6.0.4",
|
|
826
838
|
"@types/node": "^20.8.9",
|
|
827
839
|
"@types/which": "^3.0.2",
|
|
@@ -1061,6 +1073,8 @@ var ctx_default = (options) => {
|
|
|
1061
1073
|
waitForPageRender: config.waitForPageRender || 0,
|
|
1062
1074
|
waitForTimeout: config.waitForTimeout || 0,
|
|
1063
1075
|
enableJavaScript: config.enableJavaScript || false,
|
|
1076
|
+
cliEnableJavaScript: config.cliEnableJavaScript || true,
|
|
1077
|
+
scrollTime: config.scrollTime || constants_default.DEFAULT_SCROLL_TIME,
|
|
1064
1078
|
allowedHostnames: config.allowedHostnames || []
|
|
1065
1079
|
},
|
|
1066
1080
|
uploadFilePath: "",
|
|
@@ -1403,8 +1417,9 @@ function getMobileRenderViewports(ctx) {
|
|
|
1403
1417
|
}
|
|
1404
1418
|
function getRenderViewports(ctx) {
|
|
1405
1419
|
let mobileRenderViewports = getMobileRenderViewports(ctx);
|
|
1420
|
+
let webRenderViewports = getWebRenderViewports(ctx);
|
|
1406
1421
|
return [
|
|
1407
|
-
...
|
|
1422
|
+
...webRenderViewports,
|
|
1408
1423
|
...mobileRenderViewports[constants_default.MOBILE_OS_IOS],
|
|
1409
1424
|
...mobileRenderViewports[constants_default.MOBILE_OS_ANDROID]
|
|
1410
1425
|
];
|
|
@@ -1479,14 +1494,14 @@ function processSnapshot(snapshot, ctx) {
|
|
|
1479
1494
|
ctx.log.debug(`Processing snapshot ${snapshot.name}`);
|
|
1480
1495
|
let launchOptions = { headless: true };
|
|
1481
1496
|
let contextOptions = {
|
|
1482
|
-
javaScriptEnabled: ctx.config.
|
|
1497
|
+
javaScriptEnabled: ctx.config.cliEnableJavaScript,
|
|
1483
1498
|
userAgent: constants_default.CHROME_USER_AGENT
|
|
1484
1499
|
};
|
|
1485
1500
|
if (!((_a = ctx.browser) == null ? void 0 : _a.isConnected())) {
|
|
1486
1501
|
if (ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY)
|
|
1487
1502
|
launchOptions.proxy = { server: ctx.env.HTTP_PROXY || ctx.env.HTTPS_PROXY };
|
|
1488
|
-
ctx.browser = yield test.
|
|
1489
|
-
ctx.log.debug(`
|
|
1503
|
+
ctx.browser = yield test.chromium.launch(launchOptions);
|
|
1504
|
+
ctx.log.debug(`Chromium launched with options ${JSON.stringify(launchOptions)}`);
|
|
1490
1505
|
}
|
|
1491
1506
|
const context = yield ctx.browser.newContext(contextOptions);
|
|
1492
1507
|
ctx.log.debug(`Browser context created with options ${JSON.stringify(contextOptions)}`);
|
|
@@ -1600,8 +1615,13 @@ function processSnapshot(snapshot, ctx) {
|
|
|
1600
1615
|
}
|
|
1601
1616
|
}
|
|
1602
1617
|
let navigated = false;
|
|
1618
|
+
let previousDeviceType = null;
|
|
1603
1619
|
let renderViewports = getRenderViewports(ctx);
|
|
1604
|
-
for (const { viewport, viewportString, fullPage } of renderViewports) {
|
|
1620
|
+
for (const { viewport, viewportString, fullPage, device } of renderViewports) {
|
|
1621
|
+
if (previousDeviceType !== null && previousDeviceType !== device) {
|
|
1622
|
+
navigated = false;
|
|
1623
|
+
}
|
|
1624
|
+
previousDeviceType = device;
|
|
1605
1625
|
yield page.setViewportSize({ width: viewport.width, height: viewport.height || MIN_VIEWPORT_HEIGHT });
|
|
1606
1626
|
ctx.log.debug(`Page resized to ${viewport.width}x${viewport.height || MIN_VIEWPORT_HEIGHT}`);
|
|
1607
1627
|
if (!navigated) {
|
|
@@ -1617,14 +1637,15 @@ function processSnapshot(snapshot, ctx) {
|
|
|
1617
1637
|
throw new Error(error.message);
|
|
1618
1638
|
}
|
|
1619
1639
|
}
|
|
1620
|
-
if (ctx.config.
|
|
1621
|
-
yield page.evaluate(scrollToBottomAndBackToTop);
|
|
1640
|
+
if (ctx.config.cliEnableJavaScript && fullPage)
|
|
1641
|
+
yield page.evaluate(scrollToBottomAndBackToTop, { frequency: 100, timing: ctx.config.scrollTime });
|
|
1622
1642
|
try {
|
|
1623
1643
|
yield page.waitForLoadState("networkidle", { timeout: 5e3 });
|
|
1624
1644
|
ctx.log.debug("Network idle 500ms");
|
|
1625
1645
|
} catch (error) {
|
|
1626
1646
|
ctx.log.debug(`Network idle failed due to ${error}`);
|
|
1627
1647
|
}
|
|
1648
|
+
yield new Promise((r) => setTimeout(r, 1e3));
|
|
1628
1649
|
if (processedOptions.element) {
|
|
1629
1650
|
let l = yield page.locator(processedOptions.element).all();
|
|
1630
1651
|
if (l.length === 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambdatest/smartui-cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
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.
|
|
21
|
-
"@playwright/browser-firefox": "^1.
|
|
22
|
-
"@playwright/browser-webkit": "^1.
|
|
23
|
-
"@playwright/test": "^1.
|
|
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",
|
|
24
24
|
"@types/cross-spawn": "^6.0.4",
|
|
25
25
|
"@types/node": "^20.8.9",
|
|
26
26
|
"@types/which": "^3.0.2",
|