mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
It is basically a cosmetic thing, but has the following advantages: 1. Consistency with the official node documentation. The prefix is used there. 2. It is easier to recognize the build-in modules.
27 lines
858 B
JavaScript
27 lines
858 B
JavaScript
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 });
|
|
// 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 () => {
|
|
const res = await fetch("http://localhost:8080");
|
|
expect(res.status).toBe(200);
|
|
});
|
|
|
|
it("get request from http://localhost:8080/nothing should return 404", async () => {
|
|
const res = await fetch("http://localhost:8080/nothing");
|
|
expect(res.status).toBe(404);
|
|
});
|
|
});
|