Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/playwright-158-dry-run-parser.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@trigger.dev/build": patch
---

Playwright 1.58+ deployments can now install browser binaries correctly.
48 changes: 48 additions & 0 deletions packages/build/src/extensions/playwright.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { describe, expect, it } from "vitest";
import type { BuildContext, BuildLayer } from "@trigger.dev/core/v3/build";
import type { BuildManifest } from "@trigger.dev/core/v3";
import { playwright } from "./playwright.js";

function runExtension(browsers: ("chromium" | "firefox" | "webkit")[]): BuildLayer | undefined {
let captured: BuildLayer | undefined;

const context = {
target: "deploy",
config: { project: "proj_test" },
logger: {
debug() {},
},
addLayer: (layer: BuildLayer) => {
captured = layer;
},
} as unknown as BuildContext;

const manifest = {
externals: [{ name: "playwright", version: "1.58.0" }],
} as unknown as BuildManifest;

playwright({ browsers }).onBuildComplete!(context, manifest);

return captured;
}

describe("playwright extension browser metadata parsing", () => {
it("matches the legacy and Playwright 1.58 dry-run headers", () => {
const instructions = runExtension(["chromium"])?.image?.instructions ?? [];

expect(instructions).toContain(
"RUN grep -A5 -m1 -E '^(browser: chromium-headless-shell( |$)|.*\\(playwright chromium-headless-shell v)' /tmp/browser-info.txt > /tmp/chromium-headless-shell-info.txt"
);
});

it("uses a browser-specific selector for each requested browser", () => {
const instructions = runExtension(["chromium", "firefox"])?.image?.instructions ?? [];

expect(instructions).toContain(
"RUN grep -A5 -m1 -E '^(browser: chromium-headless-shell( |$)|.*\\(playwright chromium-headless-shell v)' /tmp/browser-info.txt > /tmp/chromium-headless-shell-info.txt"
);
expect(instructions).toContain(
"RUN grep -A5 -m1 -E '^(browser: firefox( |$)|.*\\(playwright firefox v)' /tmp/browser-info.txt > /tmp/firefox-info.txt"
);
});
});
2 changes: 1 addition & 1 deletion packages/build/src/extensions/playwright.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class PlaywrightExtension implements BuildExtension {

Array.from(browsersToInstall).forEach((browser) => {
instructions.push(
`RUN grep -A5 -m1 "browser: ${browser}" /tmp/browser-info.txt > /tmp/${browser}-info.txt`,
`RUN grep -A5 -m1 -E '^(browser: ${browser}( |$)|.*\\(playwright ${browser} v)' /tmp/browser-info.txt > /tmp/${browser}-info.txt`,

`RUN INSTALL_DIR=$(grep "Install location:" /tmp/${browser}-info.txt | cut -d':' -f2- | xargs) && \
DIR_NAME=$(basename "$INSTALL_DIR") && \
Expand Down