mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
refactor e2e
This commit is contained in:
parent
c15b31b374
commit
9969fede35
@ -37,7 +37,7 @@
|
||||
time: Function.prototype.bind.call(console.time, console),
|
||||
timeEnd: Function.prototype.bind.call(console.timeEnd, console),
|
||||
timeStamp: Function.prototype.bind.call(console.timeStamp, console)
|
||||
}
|
||||
};
|
||||
|
||||
logLevel.setLogLevel = function (newLevel) {
|
||||
if (newLevel) {
|
||||
|
@ -95,8 +95,7 @@ function Server(config, callback) {
|
||||
|
||||
this.close = function () {
|
||||
server.close();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = Server;
|
||||
|
@ -125,6 +125,9 @@
|
||||
],
|
||||
"modulePaths": [
|
||||
"<rootDir>/js/"
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"<rootDir>/tests/e2e/global-setup.js"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -1,15 +1,13 @@
|
||||
const fetch = require("node-fetch");
|
||||
const app = require("app.js");
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("Electron app environment", function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
||||
|
||||
app.start();
|
||||
app = helpers.startApplication("tests/configs/env.js");
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
app.stop();
|
||||
helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
it("get request from http://localhost:8080 should return 200", function (done) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
const fetch = require("node-fetch");
|
||||
const app = require("app.js");
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("All font files from roboto.css should be downloadable", function () {
|
||||
const fontFiles = [];
|
||||
@ -15,13 +16,10 @@ describe("All font files from roboto.css should be downloadable", function () {
|
||||
}
|
||||
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/without_modules.js";
|
||||
|
||||
app.start();
|
||||
app = helpers.startApplication("tests/configs/without_modules.js");
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
app.stop();
|
||||
helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
test.each(fontFiles)("should return 200 HTTP code for file '%s'", (fontFile, done) => {
|
||||
|
16
tests/e2e/global-setup.js
Normal file
16
tests/e2e/global-setup.js
Normal file
@ -0,0 +1,16 @@
|
||||
exports.startApplication = function (configFilename, exec) {
|
||||
jest.resetModules();
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = configFilename;
|
||||
if (exec) exec;
|
||||
const app = require("app.js");
|
||||
app.start();
|
||||
|
||||
return app;
|
||||
};
|
||||
|
||||
exports.stopApplication = function (app) {
|
||||
if (app) {
|
||||
app.stop();
|
||||
}
|
||||
};
|
@ -1,19 +1,14 @@
|
||||
const fetch = require("node-fetch");
|
||||
const app = require("app.js");
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("ipWhitelist directive configuration", function () {
|
||||
beforeAll(function () {
|
||||
app.start();
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
app.stop();
|
||||
});
|
||||
|
||||
describe("Set ipWhitelist without access", function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/noIpWhiteList.js";
|
||||
app = helpers.startApplication("tests/configs/noIpWhiteList.js");
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
it("should return 403", function (done) {
|
||||
@ -26,8 +21,10 @@ describe("ipWhitelist directive configuration", function () {
|
||||
|
||||
describe("Set ipWhitelist []", function () {
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/empty_ipWhiteList.js";
|
||||
app = helpers.startApplication("tests/configs/empty_ipWhiteList.js");
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
it("should return 200", function (done) {
|
||||
|
@ -1,18 +1,16 @@
|
||||
const fetch = require("node-fetch");
|
||||
const app = require("app.js");
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("port directive configuration", function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/port_8090.js";
|
||||
|
||||
app.start();
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
app.stop();
|
||||
});
|
||||
|
||||
describe("Set port 8090", function () {
|
||||
beforeAll(function () {
|
||||
app = helpers.startApplication("tests/configs/port_8090.js");
|
||||
});
|
||||
afterAll(function () {
|
||||
helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
it("should return 200", function (done) {
|
||||
fetch("http://localhost:8090").then((res) => {
|
||||
expect(res.status).toBe(200);
|
||||
@ -23,11 +21,10 @@ describe("port directive configuration", function () {
|
||||
|
||||
describe("Set port 8100 on environment variable MM_PORT", function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_PORT = 8100;
|
||||
app = helpers.startApplication("tests/configs/port_8090.js", (process.env.MM_PORT = 8100));
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
delete process.env.MM_PORT;
|
||||
helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
it("should return 200", function (done) {
|
||||
|
@ -1,15 +1,13 @@
|
||||
const fetch = require("node-fetch");
|
||||
const app = require("app.js");
|
||||
const helpers = require("./global-setup");
|
||||
let app = null;
|
||||
|
||||
describe("Vendors", function () {
|
||||
beforeAll(function () {
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
||||
|
||||
app.start();
|
||||
app = helpers.startApplication("tests/configs/env.js");
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
app.stop();
|
||||
helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
describe("Get list vendors", function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user