mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
refactor tests
This commit is contained in:
parent
f3cefde7cb
commit
8cb6015930
4
.github/workflows/automated-tests.yml
vendored
4
.github/workflows/automated-tests.yml
vendored
@ -33,6 +33,4 @@ jobs:
|
|||||||
npm run test:prettier
|
npm run test:prettier
|
||||||
npm run test:js
|
npm run test:js
|
||||||
npm run test:css
|
npm run test:css
|
||||||
npm run test:unit
|
npm run test
|
||||||
npm run test:e2e
|
|
||||||
npm run test:electron
|
|
||||||
|
@ -95,6 +95,7 @@
|
|||||||
"jest": {
|
"jest": {
|
||||||
"verbose": true,
|
"verbose": true,
|
||||||
"testTimeout": 15000,
|
"testTimeout": 15000,
|
||||||
|
"testSequencer": "<rootDir>/tests/configs/test_sequencer.js",
|
||||||
"projects": [
|
"projects": [
|
||||||
{
|
{
|
||||||
"displayName": "unit",
|
"displayName": "unit",
|
||||||
|
26
tests/configs/test_sequencer.js
Normal file
26
tests/configs/test_sequencer.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
const TestSequencer = require("@jest/test-sequencer").default;
|
||||||
|
|
||||||
|
class CustomSequencer extends TestSequencer {
|
||||||
|
sort(tests) {
|
||||||
|
const orderPath = ["unit", "e2e", "electron"];
|
||||||
|
return tests.sort((testA, testB) => {
|
||||||
|
let indexA = -1;
|
||||||
|
let indexB = -1;
|
||||||
|
const reg = ".*/tests/([^/]*).*";
|
||||||
|
|
||||||
|
let matchA = new RegExp(reg, "g").exec(testA.path);
|
||||||
|
if (matchA.length > 0) indexA = orderPath.indexOf(matchA[1]);
|
||||||
|
|
||||||
|
let matchB = new RegExp(reg, "g").exec(testB.path);
|
||||||
|
if (matchB.length > 0) indexB = orderPath.indexOf(matchB[1]);
|
||||||
|
|
||||||
|
if (indexA === indexB) return 0;
|
||||||
|
|
||||||
|
if (indexA === -1) return 1;
|
||||||
|
if (indexB === -1) return -1;
|
||||||
|
return indexA < indexB ? -1 : 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = CustomSequencer;
|
@ -1,5 +1,6 @@
|
|||||||
const helpers = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
const serverBasicAuth = require("./basic-auth.js");
|
const serverBasicAuth = require("./basic-auth.js");
|
||||||
|
const testDelay = 4000;
|
||||||
|
|
||||||
describe("Calendar module", function () {
|
describe("Calendar module", function () {
|
||||||
/**
|
/**
|
||||||
@ -24,7 +25,7 @@ describe("Calendar module", function () {
|
|||||||
describe("Default configuration", function () {
|
describe("Default configuration", function () {
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/default.js");
|
helpers.startApplication("tests/configs/modules/calendar/default.js");
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the default maximumEntries of 10", () => {
|
it("should show the default maximumEntries of 10", () => {
|
||||||
@ -39,7 +40,7 @@ describe("Calendar module", function () {
|
|||||||
describe("Custom configuration", function () {
|
describe("Custom configuration", function () {
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/custom.js");
|
helpers.startApplication("tests/configs/modules/calendar/custom.js");
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the custom maximumEntries of 4", () => {
|
it("should show the custom maximumEntries of 4", () => {
|
||||||
@ -62,7 +63,7 @@ describe("Calendar module", function () {
|
|||||||
describe("Recurring event", function () {
|
describe("Recurring event", function () {
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the recurring birthday event 6 times", () => {
|
it("should show the recurring birthday event 6 times", () => {
|
||||||
@ -78,7 +79,7 @@ describe("Calendar module", function () {
|
|||||||
return i * 60;
|
return i * 60;
|
||||||
};
|
};
|
||||||
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
helpers.startApplication("tests/configs/modules/calendar/recurring.js");
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should contain text "Mar 25th" in timezone UTC ' + -i, () => {
|
it('should contain text "Mar 25th" in timezone UTC ' + -i, () => {
|
||||||
@ -93,7 +94,7 @@ describe("Calendar module", function () {
|
|||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/changed-port.js");
|
helpers.startApplication("tests/configs/modules/calendar/changed-port.js");
|
||||||
serverBasicAuth.listen(8010);
|
serverBasicAuth.listen(8010);
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(function (done) {
|
afterAll(function (done) {
|
||||||
@ -108,7 +109,7 @@ describe("Calendar module", function () {
|
|||||||
describe("Basic auth", function () {
|
describe("Basic auth", function () {
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/basic-auth.js");
|
helpers.startApplication("tests/configs/modules/calendar/basic-auth.js");
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return TestEvents", function () {
|
it("should return TestEvents", function () {
|
||||||
@ -119,7 +120,7 @@ describe("Calendar module", function () {
|
|||||||
describe("Basic auth by default", function () {
|
describe("Basic auth by default", function () {
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/auth-default.js");
|
helpers.startApplication("tests/configs/modules/calendar/auth-default.js");
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return TestEvents", function () {
|
it("should return TestEvents", function () {
|
||||||
@ -130,7 +131,7 @@ describe("Calendar module", function () {
|
|||||||
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
|
describe("Basic auth backward compatibility configuration: DEPRECATED", function () {
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js");
|
helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js");
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should return TestEvents", function () {
|
it("should return TestEvents", function () {
|
||||||
@ -142,7 +143,7 @@ describe("Calendar module", function () {
|
|||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js");
|
helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js");
|
||||||
serverBasicAuth.listen(8020);
|
serverBasicAuth.listen(8020);
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(function (done) {
|
afterAll(function (done) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const helpers = require("../global-setup");
|
const helpers = require("../global-setup");
|
||||||
|
const testDelay = 4000;
|
||||||
|
|
||||||
describe("Newsfeed module", function () {
|
describe("Newsfeed module", function () {
|
||||||
afterAll(function () {
|
afterAll(function () {
|
||||||
@ -8,7 +9,7 @@ describe("Newsfeed module", function () {
|
|||||||
describe("Default configuration", function () {
|
describe("Default configuration", function () {
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/newsfeed/default.js");
|
helpers.startApplication("tests/configs/modules/newsfeed/default.js");
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show the newsfeed title", function () {
|
it("should show the newsfeed title", function () {
|
||||||
@ -32,7 +33,7 @@ describe("Newsfeed module", function () {
|
|||||||
describe("Custom configuration", function () {
|
describe("Custom configuration", function () {
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js");
|
helpers.startApplication("tests/configs/modules/newsfeed/prohibited_words.js");
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not show articles with prohibited words", function () {
|
it("should not show articles with prohibited words", function () {
|
||||||
@ -51,7 +52,7 @@ describe("Newsfeed module", function () {
|
|||||||
describe("Invalid configuration", function () {
|
describe("Invalid configuration", function () {
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js");
|
helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js");
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show malformed url warning", function () {
|
it("should show malformed url warning", function () {
|
||||||
@ -64,7 +65,7 @@ describe("Newsfeed module", function () {
|
|||||||
describe("Ignore items", function () {
|
describe("Ignore items", function () {
|
||||||
beforeAll(function (done) {
|
beforeAll(function (done) {
|
||||||
helpers.startApplication("tests/configs/modules/newsfeed/ignore_items.js");
|
helpers.startApplication("tests/configs/modules/newsfeed/ignore_items.js");
|
||||||
helpers.getDocument(done, 3000);
|
helpers.getDocument(done, testDelay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show empty items info message", function () {
|
it("should show empty items info message", function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user