diff --git a/CHANGELOG.md b/CHANGELOG.md index 53a24bee..d715591c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ _This release is scheduled to be released on 2023-07-01._ ### Added +- Added tests for severonly + ### Removed - Removed unneeded (and unwanted) '.' after the year in calendar repeatingCountTitle (#2896, second attempt ...) diff --git a/tests/configs/port_variable.js.template b/tests/configs/port_variable.js.template index 3d8d9791..0a0d58bb 100644 --- a/tests/configs/port_variable.js.template +++ b/tests/configs/port_variable.js.template @@ -3,7 +3,7 @@ * By Rodrigo Ramírez Norambuena https://rodrigoramirez.com * MIT Licensed. */ -let config = require(process.cwd() + "/tests/configs/default.js").configFactory({ +let config = require(`${process.cwd()}/tests/configs/default.js`).configFactory({ port: ${MM_PORT} }); diff --git a/tests/e2e/serveronly_spec.js b/tests/e2e/serveronly_spec.js new file mode 100644 index 00000000..78ecba30 --- /dev/null +++ b/tests/e2e/serveronly_spec.js @@ -0,0 +1,28 @@ +const helpers = require("./helpers/global-setup"); + +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("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 helpers.fetch("http://localhost:8080"); + expect(res.status).toBe(200); + }); + + it("get request from http://localhost:8080/nothing should return 404", async () => { + const res = await helpers.fetch("http://localhost:8080/nothing"); + expect(res.status).toBe(404); + }); +});