mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-22 05:07:05 +00:00
fixes e2e tests (#3817)
- fix newsfeed and calendar e2e tests so they don't need `--forceExit` anymore - `--forceExit` should stay in test runs to avoid running until test limit in case of errors - remove mocking console, not needed anymore - configFactory-stuff should not run in browser (otherwise we get errors `[ReferenceError: exports is not defined]`)
This commit is contained in:
@@ -48,6 +48,7 @@ planned for 2025-07-01
|
|||||||
- [feat] Add rule `no-undef` in config file validation to fix #3785 (#3786)
|
- [feat] Add rule `no-undef` in config file validation to fix #3785 (#3786)
|
||||||
- [fonts] Fix `roboto.css` to avoid error message `Unknown descriptor 'var(' in @font-face rule.` in firefox console (#3787)
|
- [fonts] Fix `roboto.css` to avoid error message `Unknown descriptor 'var(' in @font-face rule.` in firefox console (#3787)
|
||||||
- [tests] Fix and refactor e2e test `Same keys` in `translations_spec.js` (#3809)
|
- [tests] Fix and refactor e2e test `Same keys` in `translations_spec.js` (#3809)
|
||||||
|
- [tests] Fix e2e tests newsfeed and calendar to exit without open handles (#3817)
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
|
|
||||||
|
@@ -20,7 +20,6 @@ module.exports = async () => {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: "e2e",
|
displayName: "e2e",
|
||||||
setupFilesAfterEnv: ["<rootDir>/tests/e2e/helpers/mock-console.js"],
|
|
||||||
testMatch: ["**/tests/e2e/**/*.[jt]s?(x)"],
|
testMatch: ["**/tests/e2e/**/*.[jt]s?(x)"],
|
||||||
modulePaths: ["<rootDir>/js/"],
|
modulePaths: ["<rootDir>/js/"],
|
||||||
testPathIgnorePatterns: ["<rootDir>/tests/e2e/helpers", "<rootDir>/tests/e2e/mocks"]
|
testPathIgnorePatterns: ["<rootDir>/tests/e2e/helpers", "<rootDir>/tests/e2e/mocks"]
|
||||||
|
@@ -81,10 +81,13 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn
|
|||||||
* Schedule the timer for the next update.
|
* Schedule the timer for the next update.
|
||||||
*/
|
*/
|
||||||
const scheduleTimer = function () {
|
const scheduleTimer = function () {
|
||||||
|
if (process.env.JEST_WORKER_ID === undefined) {
|
||||||
|
// only set timer when not running in jest
|
||||||
clearTimeout(reloadTimer);
|
clearTimeout(reloadTimer);
|
||||||
reloadTimer = setTimeout(function () {
|
reloadTimer = setTimeout(function () {
|
||||||
fetchCalendar();
|
fetchCalendar();
|
||||||
}, reloadInterval);
|
}, reloadInterval);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* public methods */
|
/* public methods */
|
||||||
|
@@ -128,10 +128,13 @@ const NewsfeedFetcher = function (url, reloadInterval, encoding, logFeedWarnings
|
|||||||
* Schedule the timer for the next update.
|
* Schedule the timer for the next update.
|
||||||
*/
|
*/
|
||||||
const scheduleTimer = function () {
|
const scheduleTimer = function () {
|
||||||
|
if (process.env.JEST_WORKER_ID === undefined) {
|
||||||
|
// only set timer when not running in jest
|
||||||
clearTimeout(reloadTimer);
|
clearTimeout(reloadTimer);
|
||||||
reloadTimer = setTimeout(function () {
|
reloadTimer = setTimeout(function () {
|
||||||
fetchNews();
|
fetchNews();
|
||||||
}, reloadIntervalMS);
|
}, reloadIntervalMS);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/* public methods */
|
/* public methods */
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
if (typeof exports === "object") {
|
||||||
|
// running in nodejs (not in browser)
|
||||||
exports.configFactory = (options) => {
|
exports.configFactory = (options) => {
|
||||||
return Object.assign(
|
return Object.assign(
|
||||||
{
|
{
|
||||||
@@ -14,3 +16,4 @@ exports.configFactory = (options) => {
|
|||||||
options
|
options
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
@@ -27,6 +27,7 @@ exports.startApplication = async (configFilename, exec) => {
|
|||||||
process.env.MM_CONFIG_FILE = configFilename;
|
process.env.MM_CONFIG_FILE = configFilename;
|
||||||
}
|
}
|
||||||
process.env.mmTestMode = "true";
|
process.env.mmTestMode = "true";
|
||||||
|
process.setMaxListeners(0);
|
||||||
if (exec) exec;
|
if (exec) exec;
|
||||||
global.app = require("../../../js/app");
|
global.app = require("../../../js/app");
|
||||||
|
|
||||||
|
@@ -1,31 +0,0 @@
|
|||||||
/**
|
|
||||||
* Suppresses errors concerning web server already shut down.
|
|
||||||
* @param {string} err The error message.
|
|
||||||
*/
|
|
||||||
const mockError = (err) => {
|
|
||||||
if (
|
|
||||||
err.includes("ECONNREFUSED")
|
|
||||||
|| err.includes("ECONNRESET")
|
|
||||||
|| err.includes("socket hang up")
|
|
||||||
|| err.includes("exports is not defined")
|
|
||||||
|| err.includes("module is not defined")
|
|
||||||
|| err.includes("write EPIPE")
|
|
||||||
|| err.includes("AggregateError")
|
|
||||||
|| err.includes("ERR_SOCKET_CONNECTION_TIMEOUT")
|
|
||||||
) {
|
|
||||||
jest.fn();
|
|
||||||
} else {
|
|
||||||
console.dir(err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
global.console = {
|
|
||||||
log: jest.fn(),
|
|
||||||
dir: console.dir,
|
|
||||||
error: mockError,
|
|
||||||
warn: console.warn,
|
|
||||||
info: jest.fn(),
|
|
||||||
debug: console.debug
|
|
||||||
};
|
|
||||||
|
|
||||||
process.setMaxListeners(0);
|
|
@@ -84,9 +84,7 @@ describe("Newsfeed module", () => {
|
|||||||
describe("Newsfeed module located in config directory", () => {
|
describe("Newsfeed module located in config directory", () => {
|
||||||
beforeAll(() => {
|
beforeAll(() => {
|
||||||
const baseDir = `${__dirname}/../../..`;
|
const baseDir = `${__dirname}/../../..`;
|
||||||
if (!fs.existsSync(`${baseDir}/config/newsfeed`)) {
|
|
||||||
fs.cpSync(`${baseDir}/modules/default/newsfeed`, `${baseDir}/config/newsfeed`, { recursive: true });
|
fs.cpSync(`${baseDir}/modules/default/newsfeed`, `${baseDir}/config/newsfeed`, { recursive: true });
|
||||||
}
|
|
||||||
process.env.MM_MODULES_DIR = "config";
|
process.env.MM_MODULES_DIR = "config";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user