โšก
as-pect
  • โšกas-pect
  • ๐Ÿš€Getting Started
  • ๐Ÿ”งCLI Configuration
  • ๐Ÿ—๏ธAssemblyScript API
    • ๐Ÿ›๏ธTest Structure
    • ๐Ÿคทโ€โ™€๏ธ Expectations
      • ๐ŸŽญtoBe
      • ๐ŸคจtoStrictEqual
      • ๐ŸงฑtoBlockEqual
      • ๐Ÿ‘ฉโ€๐Ÿซ toBeTruthy and toBeFalsy
      • ๐Ÿ”ขtoBeNaN
      • ๐ŸšซtoBeNull
      • ๐ŸŒŒtoBeFinite
      • โšพtoThrow
      • โž•toBe(Greater|Less)Than
      • ๐Ÿ•ต๏ธโ€โ™€๏ธ toBeCloseTo
      • ๐Ÿ“toHaveLength
      • ๐ŸŽtoContain
      • ๐Ÿ“ฆtoContainEqual
      • โœ๏ธCustom Assertions
    • ๐ŸŽŸ๏ธTypes and Tooling
    • ๐Ÿช“Logging
    • ๐Ÿ‘ฉโ€๐Ÿ”ง RTrace and Memory Leaks
    • ๐Ÿ‘‰๐Ÿ‘ˆ Reflection
  • ๐ŸงถCore API
    • ๐ŸงชTestContext
    • ๐Ÿ‘ขBootstrap Tests Manually
    • ๐ŸŽ›๏ธTestGroup
    • โœ”๏ธTestResult
    • โœ๏ธReporters
      • ๐ŸฉณSummaryReporter
      • ๐Ÿ’ฌVerboseReporter
      • ๐ŸฅฝJSONReporter
      • ๐Ÿ—ƒ๏ธCSVReporter
Powered by GitBook
On this page

Was this helpful?

  1. Core API

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;
PreviousTestContextNextTestGroup

Last updated 5 years ago

Was this helpful?

๐Ÿงถ
๐Ÿ‘ข