Files
MagicMirror/tests/utils/vitest-setup.js
Kristjan ESPERANTO 462abf7027 [tests] migrate from jest to vitest (#3940)
This is a big change, but I think it's a good move, as `vitest` is much
more modern than `jest`.

I'm excited about the UI watch feature (run `npm run test:ui`), for
example - it's really helpful and saves time when debugging tests. I had
to adjust a few tests because they had time related issues, but
basically we are now testing the same things - even a bit better and
less flaky (I hope).

What do you think?
2025-11-03 19:47:01 +01:00

22 lines
581 B
JavaScript

/**
* Vitest setup file for module aliasing
* This allows require("logger") to work in unit tests
*/
const Module = require("node:module");
const path = require("node:path");
// Store the original require
const originalRequire = Module.prototype.require;
// 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"));
}
// Handle all other requires normally
return originalRequire.apply(this, arguments);
};