@jawis/jates
Version:
74 lines (73 loc) • 2.42 kB
TypeScript
import { LoopController } from "loop-controller";
import { OnRogue, OnTestResult } from "@jawis/jatec";
import { ClientComProv, TestRunner } from "./internal";
export type TestExecutionControllerProv = {
onToggleRunning: () => void;
prependTestList: (ids: string[]) => void;
};
export type TestExecutionControllerDeps = {
absTestFolder: string;
timeoutms: number;
tr: TestRunner;
onRogueTest: OnRogue;
onError: (error: unknown) => void;
onTestResult: OnTestResult;
DateNow: () => number;
} & Pick<ClientComProv, "onTestStarts" | "onTestRunnerStarts" | "onTestRunnerStops">;
/**
* Runs an ordered list of test.
*
* - Handle a new test list at any time.
* - Support pause and resume.
* - Emit events for test start/stop.
* - Emit events for test execution start/stop.
* - Know nothing of the test framework practicalities, or how the test list is constructed
* - When new tests are set, when paused/pausing, the execution starts.
*
*/
export declare class TestExecutionController implements TestExecutionControllerProv {
private deps;
lc: LoopController<string>;
/**
*
*/
constructor(deps: TestExecutionControllerDeps);
/**
*
*/
onToggleRunning: () => void;
/**
*
*/
resume: () => undefined;
/**
*
*/
pause: () => Promise<"paused" | "cancelled">;
/**
*
*/
prependTestList: (ids: string[]) => void;
/**
*
*/
setTestList: (ids: string[]) => void;
/**
* Handles test frameworks, that fail (so the errors emitted here are system/internal errors.)
*
* - Sets timeout for the test framework.
* - Reports test resolve/reject after timeout as rogue.
* - No robustness. `runNextTest` handles that.
*/
private wrapRunTest;
/**
* - Pause execution, if errors are thrown. They are internal errors.
* - Guard against wrapRunTest throws sync.
* - Add timeout rejections to the test log.
* They may be user or internal errors. Impossible to tell the difference.
* e.g. user error to do 'loop infinity', or sync execute beyond timeout. The framework can't do anything about it.
* It can't interrupt. Which is also the reason for the timeout here.
* e.g. internal error if the framework forget to send `testDone`. And a million other things.
*/
private runNextTest;
}