@dapplion/benchmark
Version:
Ensures that new code does not introduce performance regressions with CI. Tracks:
34 lines (33 loc) • 962 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getParentSuite = getParentSuite;
exports.getRootSuite = getRootSuite;
exports.getAllTestsInRootSuite = getAllTestsInRootSuite;
function getParentSuite(ctx) {
const test = ctx.currentTest ?? ctx.test;
if (!test)
throw Error("this.test not set");
if (!test.parent)
throw Error("this.test.parent not set");
return test.parent;
}
function getRootSuite(suite) {
if (!suite.parent)
return suite;
return getRootSuite(suite.parent);
}
function getAllTestsInRootSuite(ctx) {
const parent = getParentSuite(ctx);
const rootSuite = getRootSuite(parent);
const tests = [];
function getTests(suite) {
for (const test of suite.tests) {
tests.push(test);
}
for (const childSuite of suite.suites) {
getTests(childSuite);
}
}
getTests(rootSuite);
return tests;
}