From 326c30cd819c1ddba55c481a80c9e9293931aa70 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 22 Jul 2026 05:34:44 +0000 Subject: [PATCH 1/3] perf(test): run unit test files in parallel Drop the shared fileParallelism: false so node-unit and workers-unit files run across all cores. The serialized run spent 180s of its 310s CI duration on module imports alone; parallel workers cut the suite from ~196s to ~82s locally. The mcp-e2e project keeps fileParallelism disabled explicitly because each file boots a real Wrangler dev server against the shared seeded e2e database. --- vitest-shared.ts | 1 - vitest.mcp-e2e.config.ts | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/vitest-shared.ts b/vitest-shared.ts index 4f35fe1ae2..29c69fdb43 100644 --- a/vitest-shared.ts +++ b/vitest-shared.ts @@ -45,7 +45,6 @@ export const sharedProjectConfig = { test: { testTimeout, hookTimeout: testTimeout, - fileParallelism: false, clearMocks: true, mockReset: true, setupFiles: [ diff --git a/vitest.mcp-e2e.config.ts b/vitest.mcp-e2e.config.ts index cfebef71d8..81053bc5f3 100644 --- a/vitest.mcp-e2e.config.ts +++ b/vitest.mcp-e2e.config.ts @@ -15,6 +15,9 @@ export default mergeConfig( include: ['**/*.mcp-e2e.test.ts'], testTimeout: mcpE2eTimeout, hookTimeout: mcpE2eTimeout, + // Each file boots a real Wrangler dev server and shares the seeded + // e2e database, so files must not run in parallel. + fileParallelism: false, }, }), ) From 8649cc255fc98a31ec8e47c43821db95658fd954 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 22 Jul 2026 05:34:45 +0000 Subject: [PATCH 2/3] fix(nx): include root vitest configs in test cache inputs The worker:test and worker:test-mcp targets only hashed project files, so edits to vitest*.ts configs or tools/ (which hold vite plugins and root-level test files picked up by the runner) returned stale cache hits. --- nx.json | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/nx.json b/nx.json index d739c183b3..7a1c0754bd 100644 --- a/nx.json +++ b/nx.json @@ -15,10 +15,22 @@ "cache": true }, "test": { - "cache": true + "cache": true, + "inputs": [ + "default", + "^default", + "{workspaceRoot}/vitest*.ts", + "{workspaceRoot}/tools/**/*" + ] }, "test-mcp": { - "cache": true + "cache": true, + "inputs": [ + "default", + "^default", + "{workspaceRoot}/vitest*.ts", + "{workspaceRoot}/tools/**/*" + ] }, "prepare-e2e-env": { "cache": true From e52169dff6b077473b24c1a1bc884d5e927ae186 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 22 Jul 2026 05:48:47 +0000 Subject: [PATCH 3/3] fix(test): give CI headroom for e2e server startup under parallel unit tests The parallel unit test workers saturate all 4 CI cores at the start of validate, and the Playwright webServer (client build + D1 migrations + Wrangler boot) timed out at the default 60s. Raise the webServer budget to 180s in CI and cap vitest at 3 workers there so Wrangler startup is not starved. --- playwright.config.ts | 4 ++++ vitest-shared.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/playwright.config.ts b/playwright.config.ts index 31f06400c4..a98ee1f939 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -27,6 +27,10 @@ export default defineConfig({ webServer: { command: webServerCommand, url: baseURL, + // Startup (client build + D1 migrations + Wrangler boot) competes with + // the parallel unit test workers at the beginning of `validate`, and the + // default 60s budget times out on 4-core CI runners. + timeout: process.env.CI ? 180_000 : 60_000, reuseExistingServer: hasExplicitBaseUrl, env: { CLOUDFLARE_ENV: 'test', diff --git a/vitest-shared.ts b/vitest-shared.ts index 29c69fdb43..cea630a07c 100644 --- a/vitest-shared.ts +++ b/vitest-shared.ts @@ -45,6 +45,10 @@ export const sharedProjectConfig = { test: { testTimeout, hookTimeout: testTimeout, + // `validate` runs this suite concurrently with Playwright and two + // Wrangler servers on 4-core CI runners; leave a core free so their + // startup is not starved by test workers. + maxWorkers: process.env.CI ? 3 : undefined, clearMocks: true, mockReset: true, setupFiles: [