diff --git a/tests/e2e/env_spec.js b/tests/e2e/env_spec.js index 65dce883..b2a7238a 100644 --- a/tests/e2e/env_spec.js +++ b/tests/e2e/env_spec.js @@ -1,14 +1,13 @@ const fetch = require("node-fetch"); const helpers = require("./global-setup"); -let app = null; describe("Electron app environment", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/default.js"); + helpers.startApplication("tests/configs/default.js"); helpers.getDocument(done); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("get request from http://localhost:8080 should return 200", function (done) { diff --git a/tests/e2e/fonts.js b/tests/e2e/fonts.js index 105b9977..54cd2d87 100644 --- a/tests/e2e/fonts.js +++ b/tests/e2e/fonts.js @@ -1,6 +1,5 @@ const fetch = require("node-fetch"); const helpers = require("./global-setup"); -let app = null; describe("All font files from roboto.css should be downloadable", function () { const fontFiles = []; @@ -16,10 +15,10 @@ describe("All font files from roboto.css should be downloadable", function () { } beforeAll(function () { - app = helpers.startApplication("tests/configs/without_modules.js"); + helpers.startApplication("tests/configs/without_modules.js"); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); test.each(fontFiles)("should return 200 HTTP code for file '%s'", (fontFile, done) => { diff --git a/tests/e2e/global-setup.js b/tests/e2e/global-setup.js index 918047fe..e524d47c 100644 --- a/tests/e2e/global-setup.js +++ b/tests/e2e/global-setup.js @@ -3,22 +3,19 @@ const config = require("../configs/empty_ipWhiteList"); exports.startApplication = function (configFilename, exec) { jest.resetModules(); - let app = global.app; - if (app) { - app.stop(); + if (global.app) { + global.app.stop(); } // Set config sample for use in test process.env.MM_CONFIG_FILE = configFilename; if (exec) exec; - app = require("app.js"); - app.start(); - global.app = app; - return app; + global.app = require("app.js"); + global.app.start(); }; -exports.stopApplication = function (app) { - if (app) { - app.stop(); +exports.stopApplication = function () { + if (global.app) { + global.app.stop(); } }; diff --git a/tests/e2e/ipWhitelist_spec.js b/tests/e2e/ipWhitelist_spec.js index eba92a3e..b518cfff 100644 --- a/tests/e2e/ipWhitelist_spec.js +++ b/tests/e2e/ipWhitelist_spec.js @@ -1,14 +1,13 @@ const fetch = require("node-fetch"); const helpers = require("./global-setup"); -let app = null; describe("ipWhitelist directive configuration", function () { describe("Set ipWhitelist without access", function () { beforeAll(function () { - app = helpers.startApplication("tests/configs/noIpWhiteList.js"); + helpers.startApplication("tests/configs/noIpWhiteList.js"); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should return 403", function (done) { @@ -21,10 +20,10 @@ describe("ipWhitelist directive configuration", function () { describe("Set ipWhitelist []", function () { beforeAll(function () { - app = helpers.startApplication("tests/configs/empty_ipWhiteList.js"); + helpers.startApplication("tests/configs/empty_ipWhiteList.js"); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should return 200", function (done) { diff --git a/tests/e2e/modules/alert_spec.js b/tests/e2e/modules/alert_spec.js index 19f657a2..a557acc5 100644 --- a/tests/e2e/modules/alert_spec.js +++ b/tests/e2e/modules/alert_spec.js @@ -1,13 +1,12 @@ const helpers = require("../global-setup"); -let app = null; describe("Alert module", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/alert/default.js"); + helpers.startApplication("tests/configs/modules/alert/default.js"); helpers.getDocument(done, 1000); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should show the welcome message", function () { diff --git a/tests/e2e/compliments_spec.js b/tests/e2e/modules/compliments_spec.js similarity index 83% rename from tests/e2e/compliments_spec.js rename to tests/e2e/modules/compliments_spec.js index aefb273e..6c0a2211 100644 --- a/tests/e2e/compliments_spec.js +++ b/tests/e2e/modules/compliments_spec.js @@ -1,5 +1,4 @@ const helpers = require("../global-setup"); -let app = null; doTest = function (complimentsArray) { let elem = document.querySelector(".compliments"); @@ -11,12 +10,12 @@ doTest = function (complimentsArray) { describe("Compliments module", function () { afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); describe("parts of days", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js"); + helpers.startApplication("tests/configs/modules/compliments/compliments_parts_day.js"); helpers.getDocument(done, 1000); }); @@ -48,7 +47,7 @@ describe("Compliments module", function () { describe("Feature anytime in compliments module", function () { describe("Set anytime and empty compliments for morning, evening and afternoon ", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js"); + helpers.startApplication("tests/configs/modules/compliments/compliments_anytime.js"); helpers.getDocument(done, 1000); }); @@ -59,7 +58,7 @@ describe("Compliments module", function () { describe("Only anytime present in configuration compliments", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js"); + helpers.startApplication("tests/configs/modules/compliments/compliments_only_anytime.js"); helpers.getDocument(done, 1000); }); @@ -72,7 +71,7 @@ describe("Compliments module", function () { describe("Feature date in compliments module", function () { describe("Set date and empty compliments for anytime, morning, evening and afternoon", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/compliments/compliments_date.js"); + helpers.startApplication("tests/configs/modules/compliments/compliments_date.js"); helpers.getDocument(done, 1000); }); diff --git a/tests/e2e/modules_display_spec.js b/tests/e2e/modules_display_spec.js index 055ff8c1..4042e810 100644 --- a/tests/e2e/modules_display_spec.js +++ b/tests/e2e/modules_display_spec.js @@ -1,13 +1,12 @@ const helpers = require("./global-setup"); -let app = null; describe("Display of modules", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/display.js"); + helpers.startApplication("tests/configs/modules/display.js"); helpers.getDocument(done); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should show the test header", function () { diff --git a/tests/e2e/modules_position_spec.js b/tests/e2e/modules_position_spec.js index c23933b0..79b9b96f 100644 --- a/tests/e2e/modules_position_spec.js +++ b/tests/e2e/modules_position_spec.js @@ -1,13 +1,12 @@ const helpers = require("./global-setup"); -let app = null; describe("Position of modules", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/modules/positions.js"); + helpers.startApplication("tests/configs/modules/positions.js"); helpers.getDocument(done, 1000); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); const positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third", "middle_center", "lower_third", "bottom_left", "bottom_center", "bottom_right", "bottom_bar", "fullscreen_above", "fullscreen_below"]; diff --git a/tests/e2e/port_config.js b/tests/e2e/port_config.js index 6f6756a4..329acab6 100644 --- a/tests/e2e/port_config.js +++ b/tests/e2e/port_config.js @@ -1,14 +1,13 @@ const fetch = require("node-fetch"); const helpers = require("./global-setup"); -let app = null; describe("port directive configuration", function () { describe("Set port 8090", function () { beforeAll(function () { - app = helpers.startApplication("tests/configs/port_8090.js"); + helpers.startApplication("tests/configs/port_8090.js"); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should return 200", function (done) { @@ -21,10 +20,10 @@ describe("port directive configuration", function () { describe("Set port 8100 on environment variable MM_PORT", function () { beforeAll(function () { - app = helpers.startApplication("tests/configs/port_8090.js", (process.env.MM_PORT = 8100)); + helpers.startApplication("tests/configs/port_8090.js", (process.env.MM_PORT = 8100)); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("should return 200", function (done) { diff --git a/tests/e2e/vendor_spec.js b/tests/e2e/vendor_spec.js index e28f2d84..f6917c0d 100644 --- a/tests/e2e/vendor_spec.js +++ b/tests/e2e/vendor_spec.js @@ -1,13 +1,12 @@ const fetch = require("node-fetch"); const helpers = require("./global-setup"); -let app = null; describe("Vendors", function () { beforeAll(function () { - app = helpers.startApplication("tests/configs/default.js"); + helpers.startApplication("tests/configs/default.js"); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); describe("Get list vendors", function () { diff --git a/tests/e2e/without_modules.js b/tests/e2e/without_modules.js index dce6c0b2..8aeeee28 100644 --- a/tests/e2e/without_modules.js +++ b/tests/e2e/without_modules.js @@ -1,13 +1,12 @@ const helpers = require("./global-setup"); -let app = null; describe("Check configuration without modules", function () { beforeAll(function (done) { - app = helpers.startApplication("tests/configs/without_modules.js"); + helpers.startApplication("tests/configs/without_modules.js"); helpers.getDocument(done, 1000); }); afterAll(function () { - helpers.stopApplication(app); + helpers.stopApplication(); }); it("Show the message MagicMirror title", function () {