๐Ÿงช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:

export interface ITestContextParameters extends ITestCollectorParameters {
    /** The test reporter for this context */
    reporter?: TestReporter;
    /** stdout and stderr */
    stdout?: IWritable;
    stderr?: IWritable;
}

export declare class TestContext extends TestCollector {
  /** Construct a TestCollector. */
  constructor(props: ITestContextParameters);

  /** An indicator if the tests passed. */
  pass: boolean; 
  
  /** However long it took for all the tests to run. */
  time: number;
  
  /** However long it took to perform test collection. */
  startupTime: number;
  
  /** Run the tests with the given instantiated wasm module. */
  run(wasm: IAspectExports): void;
}

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:

export interface ITestCollectorParameters {
    /** A provided performance configuration. Deprecated. */
    performanceConfiguration?: Partial<IPerformanceConfiguration>;
    /** Filter the tests that will run. */
    testRegex?: RegExp;
    /** Filter the groups that will run. */
    groupRegex?: RegExp;
    /** The name of the test module. */
    fileName?: string;
    /** Disable RTrace when set to `true`. */
    nortrace?: boolean;
    /** The web assembly binary for function name inspection. */
    binary?: Uint8Array;
}

export declare class TestCollector {
    /** All the collected test groups */
    testGroups: TestGroup[];
    /** The root `TestGroup` object. */
    topLevelGroup: TestGroup | null;
    /** A set of errors that were collected during the testing process. */
    errors: IWarning[];
    /** A set of warnings that were collected during the testing process. */
    warnings: IWarning[];
    /** The name of the AssemblyScript test file. */
    fileName: string;
    
    constructor(props?: ITestCollectorParameters);
    /**
     * This method creates a WebAssembly imports object with all the TestContext functions
     * bound to the TestContext.
     *
     * @param {any[]} imports - Every import item specified.
     */
    createImports(...imports: any[]): any;
}

Every other property and function in each of these classes are protected and private. None of these functions should be used in production.

Last updated