🧪
TestContext
The test runner and bootstrapper
The TestContext class contains all of the methods required for bootstrapping, test collection, test running, and statistics collection.
It has the following shape:
1
export interface ITestContextParameters extends ITestCollectorParameters {
2
/** The test reporter for this context */
3
reporter?: TestReporter;
4
/** stdout and stderr */
5
stdout?: IWritable;
6
stderr?: IWritable;
7
}
8
9
export declare class TestContext extends TestCollector {
10
/** Construct a TestCollector. */
11
constructor(props: ITestContextParameters);
12
13
/** An indicator if the tests passed. */
14
pass: boolean;
15
16
/** However long it took for all the tests to run. */
17
time: number;
18
19
/** However long it took to perform test collection. */
20
startupTime: number;
21
22
/** Run the tests with the given instantiated wasm module. */
23
run(wasm: IAspectExports): void;
24
}
Copied!
It also extends the TestCollector class. The TestCollector class is designed to help aid in the creation of the function imports and collect all the tests. It has the following shape:
1
export interface ITestCollectorParameters {
2
/** A provided performance configuration. Deprecated. */
3
performanceConfiguration?: Partial<IPerformanceConfiguration>;
4
/** Filter the tests that will run. */
5
testRegex?: RegExp;
6
/** Filter the groups that will run. */
7
groupRegex?: RegExp;
8
/** The name of the test module. */
9
fileName?: string;
10
/** Disable RTrace when set to `true`. */
11
nortrace?: boolean;
12
/** The web assembly binary for function name inspection. */
13
binary?: Uint8Array;
14
}
15
16
export declare class TestCollector {
17
/** All the collected test groups */
18
testGroups: TestGroup[];
19
/** The root `TestGroup` object. */
20
topLevelGroup: TestGroup | null;
21
/** A set of errors that were collected during the testing process. */
22
errors: IWarning[];
23
/** A set of warnings that were collected during the testing process. */
24
warnings: IWarning[];
25
/** The name of the AssemblyScript test file. */
26
fileName: string;
27
28
constructor(props?: ITestCollectorParameters);
29
/**
30
* This method creates a WebAssembly imports object with all the TestContext functions
31
* bound to the TestContext.
32
*
33
* @param {any[]} imports - Every import item specified.
34
*/
35
createImports(...imports: any[]): any;
36
}
37
Copied!
Every other property and function in each of these classes are protected and private. None of these functions should be used in production.
Copy link