From c9fa69d310a7c14bf0617359ff3262bb2f55c914 Mon Sep 17 00:00:00 2001 From: Claude Bot Date: Sat, 6 Dec 2025 00:30:29 +0000 Subject: [PATCH] fix(test): prevent expensive setup in beforeAll when test will be skipped MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On platforms where Puppeteer is unsupported (Linux arm64, Windows CI), the beforeAll hooks were still running expensive operations like `bun install` and copying files, causing timeouts. Changes: - Move skip condition check to top of file - Add early return in beforeAll hooks when test will be skipped - Disable Puppeteer pipe mode on macOS to prevent flaky "TargetCloseError: Protocol error (Target.setDiscoverTargets)" errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../next-pages/test/dev-server-puppeteer.ts | 5 +++-- .../next-pages/test/dev-server.test.ts | 19 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/test/integration/next-pages/test/dev-server-puppeteer.ts b/test/integration/next-pages/test/dev-server-puppeteer.ts index 06bf56b425..11c8848118 100644 --- a/test/integration/next-pages/test/dev-server-puppeteer.ts +++ b/test/integration/next-pages/test/dev-server-puppeteer.ts @@ -1,9 +1,9 @@ import assert from "assert"; +import { which } from "bun"; import { copyFileSync } from "fs"; import { join } from "path"; import type { ConsoleMessage, Page } from "puppeteer"; import { launch } from "puppeteer"; -import { which } from "bun"; const root = join(import.meta.dir, "../"); copyFileSync(join(root, "src/Counter1.txt"), join(root, "src/Counter.tsx")); @@ -25,7 +25,8 @@ const b = await launch({ // Inherit the stdout and stderr of the browser process. dumpio: true, // Prefer to use a pipe to connect to the browser, instead of a WebSocket. - pipe: true, + // On macOS, pipe mode can cause "TargetCloseError: Protocol error (Target.setDiscoverTargets): Target closed" + pipe: process.platform !== "darwin", // Disable timeouts. timeout: 0, protocolTimeout: 0, diff --git a/test/integration/next-pages/test/dev-server.test.ts b/test/integration/next-pages/test/dev-server.test.ts index 6a3c553c6e..aaf25dba60 100644 --- a/test/integration/next-pages/test/dev-server.test.ts +++ b/test/integration/next-pages/test/dev-server.test.ts @@ -10,9 +10,18 @@ const { parseLockfile } = install_test_helpers; expect.extend({ toMatchNodeModulesAt }); +// Chrome for Testing doesn't support arm64 yet +// https://github.com/GoogleChromeLabs/chrome-for-testing/issues/1 +// https://github.com/puppeteer/puppeteer/issues/7740 +const puppeteer_unsupported = process.platform === "linux" && process.arch === "arm64"; + +// https://github.com/oven-sh/bun/issues/11255 +const shouldSkip = puppeteer_unsupported || (isWindows && isCI); + let root = tmpdirSync(); beforeAll(async () => { + if (shouldSkip) return; await rm(root, { recursive: true, force: true }); await cp(join(import.meta.dir, "../"), root, { recursive: true, force: true }); await rm(join(root, ".next"), { recursive: true, force: true }); @@ -86,6 +95,7 @@ async function getDevServerURL() { } beforeAll(async () => { + if (shouldSkip) return; copyFileSync(join(root, "src/Counter1.txt"), join(root, "src/Counter.tsx")); const install = Bun.spawnSync([bunExe(), "i"], { @@ -116,14 +126,7 @@ afterAll(() => { } }); -// Chrome for Testing doesn't support arm64 yet -// -// https://github.com/GoogleChromeLabs/chrome-for-testing/issues/1 -// https://github.com/puppeteer/puppeteer/issues/7740 -const puppeteer_unsupported = process.platform === "linux" && process.arch === "arm64"; - -// https://github.com/oven-sh/bun/issues/11255 -test.skipIf(puppeteer_unsupported || (isWindows && isCI))( +test.skipIf(shouldSkip)( "hot reloading works on the client (+ tailwind hmr)", async () => { expect(dev_server).not.toBeUndefined();