Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ planned for 2026-01-01
- [check_config] refactor: improve error handling (#3927)
- [calendar] test: remove "Recurring event per timezone" test (#3929)
- [calendar] chore: remove `requiresVersion: "2.1.0"` (#3932)
- [tests] migrate from `jest` to `vitest` (#3940)
- [tests] migrate from `jest` to `vitest` (#3940, #3941)

### Fixed

Expand Down
5 changes: 4 additions & 1 deletion js/server_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ async function cors (req, res) {
res.send(data);
}
} catch (error) {
Log.error(error);
// Only log errors in non-test environments to keep test output clean
if (process.env.mmTestMode !== "true") {
Log.error(error);
}
res.send(error);
}
}
Expand Down
5 changes: 4 additions & 1 deletion modules/default/updatenotification/git_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ class GitHelper {
this.gitResultList.push(gitInfo);
}
} catch (e) {
Log.error(`Failed to retrieve repo info for ${repo.module}: ${e}`);
// Only log errors in non-test environments to keep test output clean
if (process.env.mmTestMode !== "true") {
Log.error(`Failed to retrieve repo info for ${repo.module}: ${e}`);
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions tests/configs/modules/calendar/symboltest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ let config = {
maximumEntries: 1,
calendars: [
{
fetchInterval: 7 * 24 * 60 * 60 * 1000,
symbol: ["calendar-check", "google"],
url: "https://ics.calendarlabs.com/76/mm3137/US_Holidays.ics"
url: "http://localhost:8080/tests/mocks/12_events.ics"
}
]
}
Expand Down
18 changes: 16 additions & 2 deletions tests/utils/vitest-setup.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
/**
* Vitest setup file for module aliasing
* Vitest setup file for module aliasing and CI logging
* This allows require("logger") to work in unit tests
*/

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

// Set test mode flag for application code to detect test environment
process.env.mmTestMode = "true";

// Store the original require
const originalRequire = Module.prototype.require;

// Track if we've already applied log level
let logLevelApplied = false;

// Override require to handle our custom aliases
Module.prototype.require = function (id) {
// Handle "logger" alias
if (id === "logger") {
return originalRequire.call(this, path.resolve(__dirname, "../../js/logger.js"));
const logger = originalRequire.call(this, path.resolve(__dirname, "../../js/logger.js"));

// Suppress debug/info logs in CI to keep output clean
if (!logLevelApplied && process.env.CI === "true") {
logger.setLogLevel("ERROR");
logLevelApplied = true;
}

return logger;
}

// Handle all other requires normally
Expand Down