|
1 | 1 | // fallow-ignore-file code-duplication |
2 | | -import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; |
| 2 | +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; |
3 | 3 | import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; |
4 | 4 | import { tmpdir } from "node:os"; |
5 | 5 | import { join } from "node:path"; |
@@ -181,26 +181,19 @@ vi.mock("../utils/orphanCleanup.js", () => ({ |
181 | 181 | }), |
182 | 182 | })); |
183 | 183 |
|
| 184 | +// Collect the heavy render module once, after Vitest has hoisted the mocks |
| 185 | +// above. Keeping this import out of a hook means parallel monorepo contention |
| 186 | +// cannot turn module collection into a `beforeAll` timeout. |
| 187 | +const renderModule = await import("./render.js"); |
| 188 | + |
184 | 189 | describe("renderLocal browser GPU config", () => { |
185 | 190 | const savedEnv = new Map<string, string | undefined>(); |
186 | | - // Pre-resolve once. The first dynamic `import("./render.js")` in this file |
187 | | - // cold-loads a heavy module graph (core + engine + producer, incl. linkedom), |
188 | | - // slow under the parallel monorepo run — the generous hook timeout that |
189 | | - // absorbs that contention now lives in vitest.config.ts (shared by all CLI |
190 | | - // suites). Importing once in `beforeAll` keeps every test fast and isolated. |
191 | | - let renderLocal: typeof import("./render.js").renderLocal; |
192 | | - let resolveBrowserGpuForCli: typeof import("./render.js").resolveBrowserGpuForCli; |
193 | | - let renderLintContinuationHint: typeof import("./render.js").renderLintContinuationHint; |
194 | | - let resetTrialState: typeof import("./render.js").__resetDeParallelRouterTrialStateForTests; |
195 | | - |
196 | | - beforeAll(async () => { |
197 | | - ({ |
198 | | - renderLocal, |
199 | | - resolveBrowserGpuForCli, |
200 | | - renderLintContinuationHint, |
201 | | - __resetDeParallelRouterTrialStateForTests: resetTrialState, |
202 | | - } = await import("./render.js")); |
203 | | - }); |
| 191 | + const { |
| 192 | + renderLocal, |
| 193 | + resolveBrowserGpuForCli, |
| 194 | + renderLintContinuationHint, |
| 195 | + __resetDeParallelRouterTrialStateForTests: resetTrialState, |
| 196 | + } = renderModule; |
204 | 197 |
|
205 | 198 | it("points strict warning-only renders to --strict-all", () => { |
206 | 199 | expect(renderLintContinuationHint(true)).toContain("--strict-all"); |
@@ -713,15 +706,9 @@ describe("renderLocal browser GPU config", () => { |
713 | 706 | }); |
714 | 707 |
|
715 | 708 | describe("renderLocal — DE parallel-router CLI trial", () => { |
716 | | - let renderLocal: typeof import("./render.js").renderLocal; |
717 | | - let resetTrialState: typeof import("./render.js").__resetDeParallelRouterTrialStateForTests; |
| 709 | + const { renderLocal, __resetDeParallelRouterTrialStateForTests: resetTrialState } = renderModule; |
718 | 710 | const savedEnv = new Map<string, string | undefined>(); |
719 | 711 |
|
720 | | - beforeAll(async () => { |
721 | | - ({ renderLocal, __resetDeParallelRouterTrialStateForTests: resetTrialState } = |
722 | | - await import("./render.js")); |
723 | | - }); |
724 | | - |
725 | 712 | beforeEach(() => { |
726 | 713 | producerState.createdJobs = []; |
727 | 714 | producerState.executeImpl = async () => undefined; |
@@ -1110,13 +1097,7 @@ describe("renderLocal — DE parallel-router CLI trial", () => { |
1110 | 1097 | }); |
1111 | 1098 |
|
1112 | 1099 | describe("checkRenderResolutionPreflight", () => { |
1113 | | - let checkRenderResolutionPreflight: typeof import("./render.js").checkRenderResolutionPreflight; |
1114 | | - |
1115 | | - // Cold-imports render.js (heavy graph); the generous hook timeout for parallel |
1116 | | - // CI contention lives in vitest.config.ts. See the note above. |
1117 | | - beforeAll(async () => { |
1118 | | - ({ checkRenderResolutionPreflight } = await import("./render.js")); |
1119 | | - }); |
| 1100 | + const { checkRenderResolutionPreflight } = renderModule; |
1120 | 1101 |
|
1121 | 1102 | // Dims must be read the same way the producer's compiler reads them: |
1122 | 1103 | // `data-width` / `data-height` on the `[data-composition-id]` root. |
|
0 commit comments