@dapplion/benchmark
Version:
Ensures that new code does not introduce performance regressions with CI. Tracks:
29 lines (28 loc) • 771 B
JavaScript
export 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;
}
export function getRootSuite(suite) {
if (!suite.parent)
return suite;
return getRootSuite(suite.parent);
}
export 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;
}