diff --git a/packages/server/src/server/plugins/index.posix.test.ts b/packages/server/src/server/plugins/index.posix.test.ts index 17f25fce3b..4fdc8c3eb4 100644 --- a/packages/server/src/server/plugins/index.posix.test.ts +++ b/packages/server/src/server/plugins/index.posix.test.ts @@ -1323,8 +1323,8 @@ export default function contribute(plugin: unknown) { describe("npm plugin installation", () => { let registry: Awaited>; - // Packing the registry starts eleven real npm processes. Give fixture construction its - // own setup budget so Windows process startup does not consume the installation journey. + // Give real npm fixture construction its own setup budget so it does not consume + // the installation journey on Windows. beforeAll(async () => { const packages = npmPluginPackages(); const fixture = packages[1]; diff --git a/scripts/test-support/npm-registry.mts b/scripts/test-support/npm-registry.mts index a0a39e27d9..5640487049 100644 --- a/scripts/test-support/npm-registry.mts +++ b/scripts/test-support/npm-registry.mts @@ -50,6 +50,7 @@ export async function startNpmRegistry(packages: FixturePackage[]) { `registry=${url}/\n//127.0.0.1:${address.port}/:_authToken=fixture-token\ncache=${root}/cache\n`, ); try { + const prepared = []; for (const [index, pkg] of packages.entries()) { const directory = path.join(root, String(index)); await mkdir(directory); @@ -65,11 +66,17 @@ export async function startNpmRegistry(packages: FixturePackage[]) { await mkdir(path.dirname(path.join(directory, file)), { recursive: true }); await writeFile(path.join(directory, file), content); } - const { stdout } = await execCommand("npm", ["pack", "--ignore-scripts", "--json"], { - cwd: directory, - }); - const packed: Array<{ filename: string }> = JSON.parse(stdout); - const artifact = await readFile(path.join(directory, packed[0].filename)); + prepared.push({ directory, manifest, pkg, index }); + } + // Pack all fixtures in one npm process instead of paying startup once per package. + const { stdout } = await execCommand( + "npm", + ["pack", "--ignore-scripts", "--json", ...prepared.map(({ directory }) => directory)], + { cwd: root }, + ); + const packed: Array<{ filename: string }> = JSON.parse(stdout); + for (const { manifest, pkg, index } of prepared) { + const artifact = await readFile(path.join(root, packed[index].filename)); const artifactPath = `/artifacts/${index}.tgz`; artifacts.set(artifactPath, artifact); const published = {