Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {
} from "./RunStoryboardFunctionTests";

describe("RunStoryboardFunctionTests", () => {
beforeAll(() => {
jest.useRealTimers();
});

it.each<[RunStoryboardFunctionTestsParams, RunStoryboardFunctionTestsResult]>(
[
[
Expand Down Expand Up @@ -186,7 +190,7 @@ describe("RunStoryboardFunctionTests", () => {
list: [true, false],
},
},
invalidFn: null,
invalidFn: null as any,
noTests: {
percentage: 0,
stats: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,24 @@ function getFunctionDebugger(): FunctionDebugger {
return functionDebugger;
}

export function RunStoryboardFunctionTests({
export async function RunStoryboardFunctionTests({
functions,
keepProcessedCoverage,
}: RunStoryboardFunctionTestsParams): RunStoryboardFunctionTestsResult {
}: RunStoryboardFunctionTestsParams): Promise<RunStoryboardFunctionTestsResult> {
const { registerStoryboardFunctions, run, getCoverage } =
getFunctionDebugger();
registerStoryboardFunctions(functions);
let total = 0;
let passed = 0;
const coverageByFunction: Record<string, CoverageReport> = {};
const validCoverages: CoverageCounts[] = [];
for (const fn of functions) {

let cursor = 0;
async function one(): Promise<void> {
if (cursor === functions.length) {
return;
}
const fn = functions[cursor];
let fnTotal = 0;
let fnPassed = 0;
const list: boolean[] = [];
Expand Down Expand Up @@ -96,7 +102,16 @@ export function RunStoryboardFunctionTests({
} else {
coverageByFunction[fn.name] = null;
}
cursor++;
return new Promise((resolve) => {
setTimeout(() => {
resolve(one());
}, 0);
});
}

await one();

return {
coverage: accumulateCoverageReport(validCoverages, {
total,
Expand Down