test(e2e): add frontend smoke coverage
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const projectDir = process.cwd();
|
||||
const standaloneDir = path.join(projectDir, ".next", "standalone");
|
||||
const standalonePublicDir = path.join(standaloneDir, "public");
|
||||
const standaloneStaticDir = path.join(standaloneDir, ".next", "static");
|
||||
|
||||
fs.rmSync(standalonePublicDir, { recursive: true, force: true });
|
||||
fs.rmSync(standaloneStaticDir, { recursive: true, force: true });
|
||||
fs.cpSync(path.join(projectDir, "public"), standalonePublicDir, {
|
||||
recursive: true,
|
||||
});
|
||||
fs.mkdirSync(path.dirname(standaloneStaticDir), { recursive: true });
|
||||
fs.cpSync(path.join(projectDir, ".next", "static"), standaloneStaticDir, {
|
||||
recursive: true,
|
||||
});
|
||||
|
||||
const server = spawn(process.execPath, [path.join(standaloneDir, "server.js")], {
|
||||
cwd: standaloneDir,
|
||||
env: {
|
||||
...process.env,
|
||||
HOSTNAME: "127.0.0.1",
|
||||
PORT: "3100",
|
||||
},
|
||||
stdio: "inherit",
|
||||
});
|
||||
|
||||
const stopServer = (signal) => {
|
||||
if (!server.killed) server.kill(signal);
|
||||
};
|
||||
|
||||
process.once("SIGINT", () => stopServer("SIGINT"));
|
||||
process.once("SIGTERM", () => stopServer("SIGTERM"));
|
||||
server.once("exit", (code, signal) => {
|
||||
process.exitCode = signal ? 1 : (code ?? 1);
|
||||
});
|
||||
Reference in New Issue
Block a user