👢
Bootstrap Tests Manually
Pull yourself up by the bootstraps.
To use the@as-pect/core package, install the latest version from github along with @as-pect/assembly.
$ npm install --save-dev @as-pect/core @as-pect/assembly
To create a TestContext simply import it and instantiate it.
import { TestContext, EmptyReporter } from "@as-pect/core";
import { instantiateBuffer } from "assemblyscript/lib/loader";
class Reporter extends EmptyReporter {
constructor() { super(); }
// implement the reporter functions here
}
const binary = await fetch("./path/to/test/binary.wasm");
const buffer = await binary.arrayBuffer();
const wasmBinary = new Uint8Array(buffer);
const ctx = new TestContext({
fileName: "test.spec.ts", // the name of your module
// groupRegex: /./, // filter the groups
// testRegex: /./, // filter the tests
// performanceConfiguration: {}, // deprecated
// nortrace: true, // disable rtrace monitoring
// stdout: null, // something that can write(input: string): void
// stderr: null, // something that can write(input: string): void
binary: wasmBinary, // the binary for test name collection
});
const imports = ctx.createImports({
// put any function imports here
});
// instantiate the module
const wasm = instantiateBuffer(wasmBinary, imports);
// run the tests
ctx.run(wasm);
// inspect the testGroups for errors and exit 1 if necessary
const groups = ctx.testGroups;
// check if the tests passed
const pass = ctx.pass;
Copy link