diff --git a/.github/workflows/automated-tests.yml b/.github/workflows/automated-tests.yml index cdd86e6a..ce359589 100644 --- a/.github/workflows/automated-tests.yml +++ b/.github/workflows/automated-tests.yml @@ -33,6 +33,4 @@ jobs: npm run test:prettier npm run test:js npm run test:css - npm run test:unit - npm run test:e2e - npm run test:electron + npm run test diff --git a/package.json b/package.json index 61c9fe8a..d7f8b39f 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "jest": { "verbose": true, "testTimeout": 15000, + "testSequencer": "/tests/configs/test_sequencer.js", "projects": [ { "displayName": "unit", diff --git a/tests/configs/test_sequencer.js b/tests/configs/test_sequencer.js new file mode 100644 index 00000000..5c999e1b --- /dev/null +++ b/tests/configs/test_sequencer.js @@ -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; diff --git a/tests/e2e/modules/calendar_spec.js b/tests/e2e/modules/calendar_spec.js index 8755eb2c..929b9f57 100644 --- a/tests/e2e/modules/calendar_spec.js +++ b/tests/e2e/modules/calendar_spec.js @@ -1,5 +1,6 @@ const helpers = require("../global-setup"); const serverBasicAuth = require("./basic-auth.js"); +const testDelay = 4000; describe("Calendar module", function () { /** @@ -24,7 +25,7 @@ describe("Calendar module", function () { describe("Default configuration", function () { beforeAll(function (done) { helpers.startApplication("tests/configs/modules/calendar/default.js"); - helpers.getDocument(done, 3000); + helpers.getDocument(done, testDelay); }); it("should show the default maximumEntries of 10", () => { @@ -39,7 +40,7 @@ describe("Calendar module", function () { describe("Custom configuration", function () { beforeAll(function (done) { helpers.startApplication("tests/configs/modules/calendar/custom.js"); - helpers.getDocument(done, 3000); + helpers.getDocument(done, testDelay); }); it("should show the custom maximumEntries of 4", () => { @@ -62,7 +63,7 @@ describe("Calendar module", function () { describe("Recurring event", function () { beforeAll(function (done) { 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", () => { @@ -78,7 +79,7 @@ describe("Calendar module", function () { return i * 60; }; 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, () => { @@ -93,7 +94,7 @@ describe("Calendar module", function () { beforeAll(function (done) { helpers.startApplication("tests/configs/modules/calendar/changed-port.js"); serverBasicAuth.listen(8010); - helpers.getDocument(done, 3000); + helpers.getDocument(done, testDelay); }); afterAll(function (done) { @@ -108,7 +109,7 @@ describe("Calendar module", function () { describe("Basic auth", function () { beforeAll(function (done) { helpers.startApplication("tests/configs/modules/calendar/basic-auth.js"); - helpers.getDocument(done, 3000); + helpers.getDocument(done, testDelay); }); it("should return TestEvents", function () { @@ -119,7 +120,7 @@ describe("Calendar module", function () { describe("Basic auth by default", function () { beforeAll(function (done) { helpers.startApplication("tests/configs/modules/calendar/auth-default.js"); - helpers.getDocument(done, 3000); + helpers.getDocument(done, testDelay); }); it("should return TestEvents", function () { @@ -130,7 +131,7 @@ describe("Calendar module", function () { describe("Basic auth backward compatibility configuration: DEPRECATED", function () { beforeAll(function (done) { helpers.startApplication("tests/configs/modules/calendar/old-basic-auth.js"); - helpers.getDocument(done, 3000); + helpers.getDocument(done, testDelay); }); it("should return TestEvents", function () { @@ -142,7 +143,7 @@ describe("Calendar module", function () { beforeAll(function (done) { helpers.startApplication("tests/configs/modules/calendar/fail-basic-auth.js"); serverBasicAuth.listen(8020); - helpers.getDocument(done, 3000); + helpers.getDocument(done, testDelay); }); afterAll(function (done) { diff --git a/tests/e2e/modules/newsfeed_spec.js b/tests/e2e/modules/newsfeed_spec.js index 1a7f5662..da1280dd 100644 --- a/tests/e2e/modules/newsfeed_spec.js +++ b/tests/e2e/modules/newsfeed_spec.js @@ -1,4 +1,5 @@ const helpers = require("../global-setup"); +const testDelay = 4000; describe("Newsfeed module", function () { afterAll(function () { @@ -8,7 +9,7 @@ describe("Newsfeed module", function () { describe("Default configuration", function () { beforeAll(function (done) { helpers.startApplication("tests/configs/modules/newsfeed/default.js"); - helpers.getDocument(done, 3000); + helpers.getDocument(done, testDelay); }); it("should show the newsfeed title", function () { @@ -32,7 +33,7 @@ describe("Newsfeed module", function () { describe("Custom configuration", function () { beforeAll(function (done) { 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 () { @@ -51,7 +52,7 @@ describe("Newsfeed module", function () { describe("Invalid configuration", function () { beforeAll(function (done) { helpers.startApplication("tests/configs/modules/newsfeed/incorrect_url.js"); - helpers.getDocument(done, 3000); + helpers.getDocument(done, testDelay); }); it("should show malformed url warning", function () { @@ -64,7 +65,7 @@ describe("Newsfeed module", function () { describe("Ignore items", function () { beforeAll(function (done) { 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 () {