mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
Refactor mock-data for weather-tests generation (#3000)
Refactored the mock data generation for the tests so we can use plain JSON files for the data and read it in a more general way. Comments welcome! Co-authored-by: veeck <michael@veeck.de>
This commit is contained in:
26
tests/utils/test_sequencer.js
Normal file
26
tests/utils/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;
|
Reference in New Issue
Block a user