chore: refactor tests (#3243)

This commit is contained in:
Marvin Hagemeister
2025-08-22 12:14:19 +02:00
committed by GitHub
parent 873c54bd5f
commit 5c3fe27046
7 changed files with 252 additions and 459 deletions
+27 -1
View File
@@ -73,7 +73,11 @@ export default defineConfig({
);
await withChildProcessServer(
{ cwd: tmp.dir, args: ["run", "-A", "npm:vite", "--port", "0"], env },
{
cwd: tmp.dir,
args: ["run", "-A", "--cached-only", "npm:vite", "--port", "0"],
env,
},
async (address) => await fn(address, tmp.dir),
);
}
@@ -85,6 +89,7 @@ export async function buildVite(fixtureDir: string) {
});
const builder = await createBuilder({
logLevel: "error",
root: fixtureDir,
build: {
emptyOutDir: true,
@@ -125,3 +130,24 @@ export function usingEnv(name: string, value: string) {
},
};
}
export interface ProdOptions {
cwd: string;
args?: string[];
bin?: string;
env?: Record<string, string>;
}
export async function launchProd(
options: ProdOptions,
fn: (address: string) => void | Promise<void>,
) {
return await withChildProcessServer(
{
cwd: options.cwd,
args: options.args ??
["serve", "-A", "--cached-only", "--port", "0", "_fresh/server.js"],
},
fn,
);
}