Testing
The fixture and the walkthrough a test drives a definition through the whole environment contract with, through public surfaces only. The headless host it mounts on is under Host.
@internote/canvas-sdk/testingOn this page
@internote/canvas-sdk/testing lets you check an environment without a browser.
createHeadlessCanvasHost mounts a compiled document on a clock you control. Step through its scenes, read an attribute mid-animation, press toolbar buttons, and inspect the session.
import { createHeadlessCanvasHost } from '@internote/canvas-sdk/testing';
let now = 0;
const host = createHeadlessCanvasHost({ environments: [greetingEnvironment], document, clock: () => now });
const greeting = host.sceneAt(0).environments[0];
now = 1000;
host.sceneAt(0).steps.goTo(1);
greeting.runtime.attrValue('size');
host.dispose();labelEnvironment is a small environment that uses every part of the contract: vocabulary, cues, keyframes, a toolbar and session state. runLabelWalkthrough mounts it and checks each part, and is a working example of a thorough test.
Also exported here, documented under @internote/canvas-sdk/host: createHeadlessCanvasHost, HeadlessCanvasHost, HeadlessEnvironment, HeadlessHostOptions, HeadlessScene.