kizu
Version:
An easy-to-use, fast, and defensive Typescript/Javascript test runner designed to help you to write simple, readable, and maintainable tests.
32 lines • 1.37 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sortTestResults = sortTestResults;
const isTestPassing_1 = require("./isTestPassing");
function sortTestResults(resultsByFile) {
const sortedResults = new Map();
const passingFiles = [];
const failingFiles = [];
// Separate passing and failing files
for (const [file, tests] of Object.entries(resultsByFile)) {
const hasFailingTests = tests.some((test) => !(0, isTestPassing_1.isTestPassing)(test));
if (hasFailingTests) {
failingFiles.push([file, tests]);
}
else {
passingFiles.push([file, tests]);
}
}
// Sort passing files first, failing files last
const sortedFiles = [...passingFiles, ...failingFiles];
for (const [file, tests] of sortedFiles) {
// Sort tests: passing tests first, failing tests last
const sortedTests = [...tests].sort((a, b) => Number((0, isTestPassing_1.isTestPassing)(b)) - Number((0, isTestPassing_1.isTestPassing)(a)));
// Sort assertions inside each test: passing assertions first
for (const test of sortedTests) {
test.assertions.sort((a, b) => Number(b.pass) - Number(a.pass));
}
sortedResults.set(file, sortedTests);
}
return sortedResults;
}
//# sourceMappingURL=sortTestResults.js.map