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