2022-01-10 22:47:43 +01:00
|
|
|
const TestSequencer = require("@jest/test-sequencer").default;
|
|
|
|
|
|
|
|
class CustomSequencer extends TestSequencer {
|
2023-12-25 08:17:11 +01:00
|
|
|
sort (tests) {
|
2023-03-12 10:22:23 +01:00
|
|
|
const orderPath = ["unit", "electron", "e2e"];
|
2022-01-10 22:47:43 +01:00
|
|
|
return tests.sort((testA, testB) => {
|
|
|
|
let indexA = -1;
|
|
|
|
let indexB = -1;
|
|
|
|
const reg = ".*/tests/([^/]*).*";
|
|
|
|
|
2023-03-12 10:22:23 +01:00
|
|
|
// move calendar and newsfeed at the end
|
|
|
|
if (testA.path.includes("e2e/modules/calendar_spec") || testA.path.includes("e2e/modules/newsfeed_spec")) return 1;
|
|
|
|
if (testB.path.includes("e2e/modules/calendar_spec") || testB.path.includes("e2e/modules/newsfeed_spec")) return -1;
|
|
|
|
|
2022-01-10 22:47:43 +01:00
|
|
|
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;
|