Skip to content

Commit d7348ed

Browse files
[tests] suppress debug logs in CI environment + improve calendar symbol test stability (#3941)
## CI Log Suppression **Two-level approach for clean test output:** 1. **Suppress debug/info logs**: Call `logger.setLogLevel("ERROR")` in CI to hide verbose logging 2. **Suppress intentional error logs**: Set `mmTestMode` flag and check it before logging errors that are part of test assertions (e.g., testing error handling in `git_helper.js` and `server_functions.js`) This keeps CI output clean and makes genuine failures immediately visible, while preserving full logging for local development. **Before:** 1348 log lines with verbose debug/info output **After:** 168 log clean lines with only test results ## Calendar Symbol Test Stability Convert the calendar symbol test from external URL (`calendarlabs.com`) to existing local mock file (`12_events.ics`). This eliminates CI timeouts caused by external dependencies and improves test reliability. The test still validates the same symbol array feature but now runs faster and deterministically without network dependencies.
1 parent 462abf7 commit d7348ed

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ planned for 2026-01-01
2222
- [check_config] refactor: improve error handling (#3927)
2323
- [calendar] test: remove "Recurring event per timezone" test (#3929)
2424
- [calendar] chore: remove `requiresVersion: "2.1.0"` (#3932)
25-
- [tests] migrate from `jest` to `vitest` (#3940)
25+
- [tests] migrate from `jest` to `vitest` (#3940, #3941)
2626

2727
### Fixed
2828

js/server_functions.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ async function cors (req, res) {
5858
res.send(data);
5959
}
6060
} catch (error) {
61-
Log.error(error);
61+
// Only log errors in non-test environments to keep test output clean
62+
if (process.env.mmTestMode !== "true") {
63+
Log.error(error);
64+
}
6265
res.send(error);
6366
}
6467
}

modules/default/updatenotification/git_helper.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,10 @@ class GitHelper {
183183
this.gitResultList.push(gitInfo);
184184
}
185185
} catch (e) {
186-
Log.error(`Failed to retrieve repo info for ${repo.module}: ${e}`);
186+
// Only log errors in non-test environments to keep test output clean
187+
if (process.env.mmTestMode !== "true") {
188+
Log.error(`Failed to retrieve repo info for ${repo.module}: ${e}`);
189+
}
187190
}
188191
}
189192

tests/configs/modules/calendar/symboltest.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ let config = {
1212
maximumEntries: 1,
1313
calendars: [
1414
{
15-
fetchInterval: 7 * 24 * 60 * 60 * 1000,
1615
symbol: ["calendar-check", "google"],
17-
url: "https://ics.calendarlabs.com/76/mm3137/US_Holidays.ics"
16+
url: "http://localhost:8080/tests/mocks/12_events.ics"
1817
}
1918
]
2019
}

tests/utils/vitest-setup.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
11
/**
2-
* Vitest setup file for module aliasing
2+
* Vitest setup file for module aliasing and CI logging
33
* This allows require("logger") to work in unit tests
44
*/
55

66
const Module = require("node:module");
77
const path = require("node:path");
88

9+
// Set test mode flag for application code to detect test environment
10+
process.env.mmTestMode = "true";
11+
912
// Store the original require
1013
const originalRequire = Module.prototype.require;
1114

15+
// Track if we've already applied log level
16+
let logLevelApplied = false;
17+
1218
// Override require to handle our custom aliases
1319
Module.prototype.require = function (id) {
1420
// Handle "logger" alias
1521
if (id === "logger") {
16-
return originalRequire.call(this, path.resolve(__dirname, "../../js/logger.js"));
22+
const logger = originalRequire.call(this, path.resolve(__dirname, "../../js/logger.js"));
23+
24+
// Suppress debug/info logs in CI to keep output clean
25+
if (!logLevelApplied && process.env.CI === "true") {
26+
logger.setLogLevel("ERROR");
27+
logLevelApplied = true;
28+
}
29+
30+
return logger;
1731
}
1832

1933
// Handle all other requires normally

0 commit comments

Comments
 (0)