Skip to content

Commit 04365e3

Browse files
committed
Fixes
* Upgrade playwright to fix webkit timeout issue * Add playwright browser binaries as dependencies * Add resolutions for backward compatibility in config * Output error message when auth fails
1 parent 47eceb9 commit 04365e3

File tree

6 files changed

+60
-12
lines changed

6 files changed

+60
-12
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"author": "LambdaTest <[email protected]>",
2222
"license": "MIT",
2323
"dependencies": {
24+
"@playwright/browser-chromium": "^1.40.1",
25+
"@playwright/browser-firefox": "^1.40.1",
26+
"@playwright/browser-webkit": "^1.40.1",
27+
"@playwright/test": "^1.40.1",
2428
"@types/cross-spawn": "^6.0.4",
2529
"@types/node": "^20.8.9",
2630
"@types/which": "^3.0.2",
@@ -31,7 +35,6 @@
3135
"fastify": "^4.24.3",
3236
"form-data": "^4.0.0",
3337
"listr2": "^7.0.1",
34-
"playwright": "^1.39.0",
3538
"tsup": "^7.2.0",
3639
"which": "^4.0.0",
3740
"winston": "^3.10.0"

pnpm-lock.yaml

Lines changed: 49 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/ctx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default (options: Record<string, string>): Context => {
1515
if (options.config) {
1616
webConfig = JSON.parse(fs.readFileSync(options.config, 'utf-8'));
1717
}
18-
for (let viewport of webConfig.web.viewports) {
18+
for (let viewport of webConfig.web.resolutions || webConfig.web.viewports) {
1919
viewports.push({ width: viewport[0], height: viewport[1]})
2020
}
2121
} catch (error: any) {

src/lib/screenshot.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { chromium, firefox, webkit, Browser } from "playwright"
1+
import { chromium, firefox, webkit, Browser } from "@playwright/test"
22
import { Context, WebStaticConfigSchema } from "../types.js"
33
import { delDir } from "./utils.js"
44

@@ -7,6 +7,7 @@ const BROWSER_SAFARI = 'safari';
77
const BROWSER_FIREFOX = 'firefox';
88
const BROWSER_EDGE = 'edge';
99
const EDGE_CHANNEL = 'msedge';
10+
const PW_WEBKIT = 'webkit';
1011

1112
export async function captureScreenshots(ctx: Context, screenshots: WebStaticConfigSchema): Promise<number> {
1213
// Clean up directory to store screenshots
@@ -54,6 +55,7 @@ export async function captureScreenshots(ctx: Context, screenshots: WebStaticCon
5455
await page.screenshot({ path: ssPath, fullPage: true });
5556

5657
let completed = (i == (totalBrowsers-1) && j == (totalScreenshots-1) && k == (totalViewports-1)) ? true : false;
58+
browserName = browserName === BROWSER_SAFARI ? PW_WEBKIT : browserName;
5759
ctx.client.uploadScreenshot(ctx.build, ssPath, screenshot.name, browserName, `${width}x${height}`, completed);
5860
}
5961

src/tasks/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default (ctx: Context): ListrTask<Context, ListrRendererFactory, ListrRen
1515
task.title = 'Authenticated with SmartUI';
1616
} catch (error: any) {
1717
ctx.log.debug(error.message);
18+
task.output = chalk.gray(error.message);
1819
throw new Error('Authentication failed');
1920
}
2021
},

src/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ export interface Build {
5454
export interface WebConfigSchema {
5555
web: {
5656
browsers: Array<string>;
57-
viewports: Array<Array<number>>;
57+
viewports?: Array<Array<number>>;
58+
resolutions?: Array<Array<number>>; // for backward compatibility
5859
}
5960
}
6061

0 commit comments

Comments
 (0)