Skip to content

Commit aee7d94

Browse files
committed
improve config check tests
1 parent d81386f commit aee7d94

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Thanks to: @dathbe.
2525
- [clock] Add CSS to prevent line breaking of sunset/sunrise time display (#3816)
2626
- [core] Enhance system information logging format and include additional env and RAM details (#3839, #3843)
2727
- [refactor] Add new file `js/module_functions.js` to move code used in several modules to one place (#3837)
28-
- [refactor] Use global.root_path where possible and add test for config:check (#3883, #3885, #3886)
28+
- [refactor] Use global.root_path where possible and add tests for config:check (#3883, #3885, #3886, #3889)
2929
- [tests] refactor: simplify jest config file (#3844)
3030
- [tests] refactor: extract constants for weather electron tests (#3845)
3131
- [tests] refactor: add `setupDOMEnvironment` helper function to eliminate repetitive JSDOM setup code (#3860)

tests/e2e/serveronly_spec.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ const delay = (time) => {
22
return new Promise((resolve) => setTimeout(resolve, time));
33
};
44

5+
const runConfigCheck = async () => {
6+
const serverProcess = await require("node:child_process").spawnSync("node", ["--run", "config:check"], { env: process.env });
7+
expect(serverProcess.stderr.toString()).toBe("");
8+
return await serverProcess.status;
9+
};
10+
511
describe("App environment", () => {
612
let serverProcess;
713
beforeAll(async () => {
@@ -28,7 +34,11 @@ describe("App environment", () => {
2834
describe("Check config", () => {
2935
it("config check should return without errors", async () => {
3036
process.env.MM_CONFIG_FILE = "tests/configs/default.js";
31-
const serverProcess = await require("node:child_process").spawnSync("node", ["--run", "config:check"], { env: process.env });
32-
expect(serverProcess.stderr.toString()).toBe("");
37+
await expect(runConfigCheck()).resolves.toBe(0);
38+
});
39+
40+
it("config check should fail with non existent config file", async () => {
41+
process.env.MM_CONFIG_FILE = "tests/configs/not_exists.js";
42+
await expect(runConfigCheck()).resolves.toBe(1);
3343
});
3444
});

0 commit comments

Comments
 (0)