Run server on different port when running tests
This commit is contained in:
20
test/integration/setup.cjs
Normal file
20
test/integration/setup.cjs
Normal file
@@ -0,0 +1,20 @@
|
||||
console.log("\nSpawning server process...");
|
||||
const { spawn } = require("child_process");
|
||||
|
||||
module.exports = async function () {
|
||||
const child = spawn("node", ["dev-server.cjs", "--test"]);
|
||||
|
||||
child.stdout.on('data', (data) => {
|
||||
console.log(`${data}`);
|
||||
});
|
||||
|
||||
globalThis.__INTEG_TEST_SERVER_PID__ = child.pid;
|
||||
|
||||
child.stderr.on("data", (data) => {
|
||||
const str = data.toString();
|
||||
console.log("[server]", str);
|
||||
if (str.includes("localhost:3005")) {
|
||||
setTimeout(resolve, 200);
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user