mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
change missing translations log, disable console.log in unit tests
This commit is contained in:
parent
a5f7c946cc
commit
2af4009a93
@ -99,6 +99,12 @@
|
|||||||
"testMatch": [
|
"testMatch": [
|
||||||
"**/tests/unit/**/*.[jt]s?(x)"
|
"**/tests/unit/**/*.[jt]s?(x)"
|
||||||
],
|
],
|
||||||
|
"testPathIgnorePatterns": [
|
||||||
|
"<rootDir>/tests/unit/setup_unit.js"
|
||||||
|
],
|
||||||
|
"setupFiles": [
|
||||||
|
"<rootDir>/tests/unit/setup_unit.js"
|
||||||
|
],
|
||||||
"moduleNameMapper": {
|
"moduleNameMapper": {
|
||||||
"node_helper": "<rootDir>/js/node_helper.js",
|
"node_helper": "<rootDir>/js/node_helper.js",
|
||||||
"logger": "<rootDir>/js/logger.js",
|
"logger": "<rootDir>/js/logger.js",
|
||||||
|
@ -153,6 +153,7 @@ describe("Translations", function () {
|
|||||||
|
|
||||||
describe("Same keys", function () {
|
describe("Same keys", function () {
|
||||||
let base;
|
let base;
|
||||||
|
let missing = [];
|
||||||
|
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
const dom = new JSDOM(
|
const dom = new JSDOM(
|
||||||
@ -170,6 +171,10 @@ describe("Translations", function () {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterAll(function () {
|
||||||
|
console.log(missing);
|
||||||
|
});
|
||||||
|
|
||||||
for (let language in translations) {
|
for (let language in translations) {
|
||||||
if (language === "en") {
|
if (language === "en") {
|
||||||
continue;
|
continue;
|
||||||
@ -210,7 +215,7 @@ describe("Translations", function () {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.message.match(/expect.*toEqual/)) {
|
if (e.message.match(/expect.*toEqual/)) {
|
||||||
const diff = base.filter((key) => !keys.includes(key));
|
const diff = base.filter((key) => !keys.includes(key));
|
||||||
console.log(`Missing Translations for language ${language}: ${diff}`);
|
missing.push(`Missing Translations for language ${language}: ${diff}`);
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,11 @@ const vm = require("vm");
|
|||||||
|
|
||||||
const basedir = path.join(__dirname, "../../..");
|
const basedir = path.join(__dirname, "../../..");
|
||||||
|
|
||||||
const mockedWarn = () => {};
|
|
||||||
const originalWarn = console.log;
|
|
||||||
|
|
||||||
beforeAll(function () {
|
beforeAll(function () {
|
||||||
const fileName = "js/app.js";
|
const fileName = "js/app.js";
|
||||||
const filePath = path.join(basedir, fileName);
|
const filePath = path.join(basedir, fileName);
|
||||||
const code = fs.readFileSync(filePath);
|
const code = fs.readFileSync(filePath);
|
||||||
|
|
||||||
console.log = mockedWarn;
|
|
||||||
|
|
||||||
sandbox = {
|
sandbox = {
|
||||||
module: {},
|
module: {},
|
||||||
__dirname: path.dirname(filePath),
|
__dirname: path.dirname(filePath),
|
||||||
@ -33,10 +28,6 @@ beforeAll(function () {
|
|||||||
vm.runInNewContext(code, sandbox, fileName);
|
vm.runInNewContext(code, sandbox, fileName);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(function () {
|
|
||||||
console.log = originalWarn;
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("Default modules set in modules/default/defaultmodules.js", function () {
|
describe("Default modules set in modules/default/defaultmodules.js", function () {
|
||||||
const expectedDefaultModules = require("../../../modules/default/defaultmodules");
|
const expectedDefaultModules = require("../../../modules/default/defaultmodules");
|
||||||
|
|
||||||
|
@ -2,9 +2,6 @@ const fs = require("fs");
|
|||||||
const path = require("path");
|
const path = require("path");
|
||||||
const vm = require("vm");
|
const vm = require("vm");
|
||||||
|
|
||||||
const mockedWarn = () => {};
|
|
||||||
const originalWarn = console.log;
|
|
||||||
|
|
||||||
beforeAll(function () {
|
beforeAll(function () {
|
||||||
const basedir = path.join(__dirname, "../../..");
|
const basedir = path.join(__dirname, "../../..");
|
||||||
|
|
||||||
@ -12,8 +9,6 @@ beforeAll(function () {
|
|||||||
const filePath = path.join(basedir, fileName);
|
const filePath = path.join(basedir, fileName);
|
||||||
const code = fs.readFileSync(filePath);
|
const code = fs.readFileSync(filePath);
|
||||||
|
|
||||||
console.log = mockedWarn;
|
|
||||||
|
|
||||||
sandbox = {
|
sandbox = {
|
||||||
module: {},
|
module: {},
|
||||||
__dirname: path.dirname(filePath),
|
__dirname: path.dirname(filePath),
|
||||||
@ -33,10 +28,6 @@ beforeAll(function () {
|
|||||||
vm.runInNewContext(code, sandbox, fileName);
|
vm.runInNewContext(code, sandbox, fileName);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(function () {
|
|
||||||
console.log = originalWarn;
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("'global.root_path' set in js/app.js", function () {
|
describe("'global.root_path' set in js/app.js", function () {
|
||||||
const expectedSubPaths = ["modules", "serveronly", "js", "js/app.js", "js/main.js", "js/electron.js", "config"];
|
const expectedSubPaths = ["modules", "serveronly", "js", "js/app.js", "js/main.js", "js/electron.js", "config"];
|
||||||
|
|
||||||
|
1
tests/unit/setup_unit.js
Normal file
1
tests/unit/setup_unit.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
console.log = () => {};
|
Loading…
x
Reference in New Issue
Block a user