mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
fix logger.js, move jsdom in startApplication
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const jsdom = require("jsdom");
|
||||
const config = require("../configs/empty_ipWhiteList");
|
||||
|
||||
exports.startApplication = function (configFilename, exec) {
|
||||
exports.startApplication = function (configFilename, exec, callback) {
|
||||
jest.resetModules();
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = configFilename;
|
||||
@@ -8,6 +9,16 @@ exports.startApplication = function (configFilename, exec) {
|
||||
const app = require("app.js");
|
||||
app.start();
|
||||
|
||||
if (callback) {
|
||||
const url = "http://" + (config.address || "localhost") + ":" + (config.port || "8080");
|
||||
jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => {
|
||||
dom.window.onload = function () {
|
||||
global.document = dom.window.document;
|
||||
callback();
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
return app;
|
||||
};
|
||||
|
||||
@@ -16,12 +27,3 @@ exports.stopApplication = function (app) {
|
||||
app.stop();
|
||||
}
|
||||
};
|
||||
|
||||
exports.getDocument = function (url, callback) {
|
||||
jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => {
|
||||
dom.window.onload = function () {
|
||||
global.document = dom.window.document;
|
||||
callback();
|
||||
};
|
||||
});
|
||||
};
|
||||
|
Reference in New Issue
Block a user