mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
first tests
This commit is contained in:
parent
c3c5307624
commit
b4350278a0
@ -35,8 +35,8 @@
|
|||||||
groupCollapsed: Function.prototype.bind.call(console.groupCollapsed, console),
|
groupCollapsed: Function.prototype.bind.call(console.groupCollapsed, console),
|
||||||
groupEnd: Function.prototype.bind.call(console.groupEnd, console),
|
groupEnd: Function.prototype.bind.call(console.groupEnd, console),
|
||||||
time: Function.prototype.bind.call(console.time, console),
|
time: Function.prototype.bind.call(console.time, console),
|
||||||
timeEnd: Function.prototype.bind.call(console.timeEnd, console),
|
timeEnd: Function.prototype.bind.call(console.timeEnd, console)
|
||||||
timeStamp: Function.prototype.bind.call(console.timeStamp, console)
|
// timeStamp: Function.prototype.bind.call(console.timeStamp, console)
|
||||||
};
|
};
|
||||||
|
|
||||||
logLevel.setLogLevel = function (newLevel) {
|
logLevel.setLogLevel = function (newLevel) {
|
||||||
|
@ -120,6 +120,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "e2e",
|
"displayName": "e2e",
|
||||||
|
"setupFilesAfterEnv": [
|
||||||
|
"<rootDir>/tests/e2e/mock-console.js"
|
||||||
|
],
|
||||||
"testMatch": [
|
"testMatch": [
|
||||||
"**/tests/e2e/**/*.[jt]s?(x)"
|
"**/tests/e2e/**/*.[jt]s?(x)"
|
||||||
],
|
],
|
||||||
|
@ -3,7 +3,13 @@
|
|||||||
* By Rejas
|
* By Rejas
|
||||||
* MIT Licensed.
|
* MIT Licensed.
|
||||||
*/
|
*/
|
||||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory({
|
let config = {
|
||||||
|
port: 8080,
|
||||||
|
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"],
|
||||||
|
language: "en",
|
||||||
|
timeFormat: 24,
|
||||||
|
units: "metric",
|
||||||
|
|
||||||
modules: [
|
modules: [
|
||||||
{
|
{
|
||||||
module: "helloworld",
|
module: "helloworld",
|
||||||
@ -21,11 +27,7 @@ let config = require(process.cwd() + "/tests/configs/default.js").configFactory(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
};
|
||||||
|
|
||||||
config.electronOptions.fullscreen = false;
|
|
||||||
config.electronOptions.width = 800;
|
|
||||||
config.electronOptions.height = 600;
|
|
||||||
|
|
||||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||||
if (typeof module !== "undefined") {
|
if (typeof module !== "undefined") {
|
||||||
|
9
tests/e2e/mock-console.js
Normal file
9
tests/e2e/mock-console.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
global.console = {
|
||||||
|
log: console.log,
|
||||||
|
dir: console.dir,
|
||||||
|
// error: jest.fn(),
|
||||||
|
error: console.error,
|
||||||
|
warn: console.warn,
|
||||||
|
info: console.info,
|
||||||
|
debug: console.debug
|
||||||
|
};
|
37
tests/e2e/modules.js
Normal file
37
tests/e2e/modules.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
const jsdom = require("jsdom");
|
||||||
|
const fetch = require("node-fetch");
|
||||||
|
const helpers = require("./global-setup");
|
||||||
|
let app = null;
|
||||||
|
|
||||||
|
describe("test headers", function () {
|
||||||
|
beforeAll(function () {
|
||||||
|
// todo: require is not defined ...
|
||||||
|
// jest.mock("logger");
|
||||||
|
app = helpers.startApplication("tests/configs/modules/display.js");
|
||||||
|
// app = helpers.startApplication("config/config.js");
|
||||||
|
});
|
||||||
|
afterAll(function () {
|
||||||
|
helpers.stopApplication(app);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("test", function (done) {
|
||||||
|
jsdom.JSDOM.fromURL("http://localhost:8080", { resources: "usable", runScripts: "dangerously" }).then((dom) => {
|
||||||
|
// console.log(dom.serialize());
|
||||||
|
dom.window.onload = function () {
|
||||||
|
const doc = dom.window.document;
|
||||||
|
console.log(doc.querySelector("title").textContent);
|
||||||
|
const children = doc.body.getElementsByTagName("*");
|
||||||
|
for (var i = 0, length = children.length; i < length; i++) {
|
||||||
|
child = children[i];
|
||||||
|
if (child.id !== "") console.dir(child.id);
|
||||||
|
}
|
||||||
|
console.log(doc.querySelector("#module_0_helloworld .module-header").textContent);
|
||||||
|
// result ist leider lowercase wegen fehlendem css, siehe https://stackoverflow.com/questions/10318330/how-do-you-add-stylesheets-to-jsdom
|
||||||
|
// const elem = doc.getElementById("module_0_helloworld");
|
||||||
|
// console.dir(elem);
|
||||||
|
done();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
// done();
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user