Files
MagicMirror/tests/e2e/serveronly_spec.js
T

27 lines
858 B
JavaScript
Raw Normal View History

2023-07-01 21:17:31 +02:00
const delay = (time) => {
return new Promise((resolve) => setTimeout(resolve, time));
};
describe("App environment", () => {
let serverProcess;
beforeAll(async () => {
process.env.MM_CONFIG_FILE = "tests/configs/default.js";
serverProcess = await require("node:child_process").spawn("npm", ["run", "server"], { env: process.env, detached: true });
2023-07-01 21:17:31 +02:00
// we have to wait until the server is startet
await delay(2000);
});
afterAll(async () => {
await process.kill(-serverProcess.pid);
});
it("get request from http://localhost:8080 should return 200", async () => {
2023-10-01 20:13:41 +02:00
const res = await fetch("http://localhost:8080");
2023-07-01 21:17:31 +02:00
expect(res.status).toBe(200);
});
it("get request from http://localhost:8080/nothing should return 404", async () => {
2023-10-01 20:13:41 +02:00
const res = await fetch("http://localhost:8080/nothing");
2023-07-01 21:17:31 +02:00
expect(res.status).toBe(404);
});
});