mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
silence logger for tests, use modulePaths for e2e
This commit is contained in:
parent
974de179e0
commit
236bf6e0fc
61
js/logger.js
61
js/logger.js
@ -9,12 +9,13 @@
|
||||
*/
|
||||
(function (root, factory) {
|
||||
if (typeof exports === "object") {
|
||||
// add timestamps in front of log messages
|
||||
require("console-stamp")(console, {
|
||||
pattern: "yyyy-mm-dd HH:MM:ss.l",
|
||||
include: ["debug", "log", "info", "warn", "error"]
|
||||
});
|
||||
|
||||
if (process.env.JEST_WORKER_ID === undefined) {
|
||||
// add timestamps in front of log messages
|
||||
require("console-stamp")(console, {
|
||||
pattern: "yyyy-mm-dd HH:MM:ss.l",
|
||||
include: ["debug", "log", "info", "warn", "error"]
|
||||
});
|
||||
}
|
||||
// Node, CommonJS-like
|
||||
module.exports = factory(root.config);
|
||||
} else {
|
||||
@ -22,7 +23,9 @@
|
||||
root.Log = factory(root.config);
|
||||
}
|
||||
})(this, function (config) {
|
||||
let logLevel = {
|
||||
let logLevel;
|
||||
if ((typeof exports === "object" && process.env.JEST_WORKER_ID === undefined) || typeof exports !== "object") {
|
||||
logLevel = {
|
||||
debug: Function.prototype.bind.call(console.debug, console),
|
||||
log: Function.prototype.bind.call(console.log, console),
|
||||
info: Function.prototype.bind.call(console.info, console),
|
||||
@ -32,22 +35,36 @@
|
||||
groupCollapsed: Function.prototype.bind.call(console.groupCollapsed, console),
|
||||
groupEnd: Function.prototype.bind.call(console.groupEnd, console),
|
||||
time: Function.prototype.bind.call(console.time, console),
|
||||
timeEnd: Function.prototype.bind.call(console.timeEnd, console)
|
||||
};
|
||||
|
||||
if ((typeof exports === "object" && process.env.JEST_WORKER_ID === undefined) || typeof exports !== "object") {
|
||||
logLevel.timeStamp = Function.prototype.bind.call(console.timeStamp, console);
|
||||
}
|
||||
|
||||
logLevel.setLogLevel = function (newLevel) {
|
||||
if (newLevel) {
|
||||
Object.keys(logLevel).forEach(function (key, index) {
|
||||
if (!newLevel.includes(key.toLocaleUpperCase())) {
|
||||
logLevel[key] = function () {};
|
||||
}
|
||||
});
|
||||
timeEnd: Function.prototype.bind.call(console.timeEnd, console),
|
||||
timeStamp: Function.prototype.bind.call(console.timeStamp, console)
|
||||
}
|
||||
};
|
||||
|
||||
logLevel.setLogLevel = function (newLevel) {
|
||||
if (newLevel) {
|
||||
Object.keys(logLevel).forEach(function (key, index) {
|
||||
if (!newLevel.includes(key.toLocaleUpperCase())) {
|
||||
logLevel[key] = function () {};
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
} else {
|
||||
logLevel = {
|
||||
debug: function () {},
|
||||
log: function () {},
|
||||
info: function () {},
|
||||
warn: function () {},
|
||||
error: function () {},
|
||||
group: function () {},
|
||||
groupCollapsed: function () {},
|
||||
groupEnd: function () {},
|
||||
time: function () {},
|
||||
timeEnd: function () {},
|
||||
timeStamp: function () {}
|
||||
};
|
||||
|
||||
logLevel.setLogLevel = function () {};
|
||||
}
|
||||
|
||||
return logLevel;
|
||||
});
|
||||
|
@ -123,10 +123,9 @@
|
||||
"testMatch": [
|
||||
"**/tests/e2e/**/*.[jt]s?(x)"
|
||||
],
|
||||
"moduleNameMapper": {
|
||||
"logger": "<rootDir>/js/logger.js",
|
||||
"node_helper": "<rootDir>/js/node_helper.js"
|
||||
}
|
||||
"modulePaths": [
|
||||
"<rootDir>/js/"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
const fetch = require("node-fetch");
|
||||
const app = require("../../js/app.js");
|
||||
const app = require("app.js");
|
||||
|
||||
describe("Electron app environment", function () {
|
||||
beforeAll(function () {
|
||||
|
@ -1,5 +1,5 @@
|
||||
const fetch = require("node-fetch");
|
||||
const app = require("../../js/app.js");
|
||||
const app = require("app.js");
|
||||
|
||||
describe("All font files from roboto.css should be downloadable", function () {
|
||||
const fontFiles = [];
|
||||
|
@ -1,5 +1,5 @@
|
||||
const fetch = require("node-fetch");
|
||||
const app = require("../../js/app.js");
|
||||
const app = require("app.js");
|
||||
|
||||
describe("ipWhitelist directive configuration", function () {
|
||||
beforeAll(function () {
|
||||
|
@ -1,5 +1,5 @@
|
||||
const fetch = require("node-fetch");
|
||||
const app = require("../../js/app.js");
|
||||
const app = require("app.js");
|
||||
|
||||
describe("port directive configuration", function () {
|
||||
beforeAll(function () {
|
||||
|
@ -1,5 +1,5 @@
|
||||
const fetch = require("node-fetch");
|
||||
const app = require("../../js/app.js");
|
||||
const app = require("app.js");
|
||||
|
||||
describe("Vendors", function () {
|
||||
beforeAll(function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user