silence logger for tests, use modulePaths for e2e

This commit is contained in:
Karsten Hassel 2021-09-13 23:55:41 +02:00
parent 974de179e0
commit 236bf6e0fc
7 changed files with 47 additions and 31 deletions

View File

@ -9,12 +9,13 @@
*/
(function (root, factory) {
if (typeof exports === "object") {
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,11 +35,8 @@
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);
timeEnd: Function.prototype.bind.call(console.timeEnd, console),
timeStamp: Function.prototype.bind.call(console.timeStamp, console)
}
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;
});

View File

@ -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/"
]
}
]
}

View File

@ -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 () {

View File

@ -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 = [];

View File

@ -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 () {

View File

@ -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 () {

View File

@ -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 () {