@zerolith/test
Import from @zerolith/test. Generated from the source; every signature below is what the published types declare.
Functions
mount
function mount(view: unknown, options?: MountOptions): MountedRenders a view into a container and remembers it for cleanup. Given a
function that returns the view, as mount(() => Page()), it hands the
function to render, which calls it inside the root's owner, so a
component that registers cleanups with onDispose mounts as it is, and
its cleanups run when the view is unmounted. A component that takes
props, passed uncalled, fails with mount_component_uncalled, as
render does. A container mount created is removed even when
rendering throws.
Source: packages/test/src/index.ts:41
cleanup
function cleanup(): voidUnmounts everything mount created, newest first, each even when another's cleanup throws, and then throws the first error. Register it as the runner's after-each hook.
Source: packages/test/src/index.ts:89
settle
function settle(rounds?: number): Promise<void>Waits rounds turns of the timer queue, two by default: enough for
promise chains, a resource whose loader resolves at once, and zero-delay
timers. Effects run synchronously when a signal changes, so they need no
settling. For a module import or a request, wait on its result with the
runner's waitFor instead.
Source: packages/test/src/index.ts:116
hydrationMismatches
function hydrationMismatches(view: () => unknown): HydrationMismatch[]Renders view with the server renderer, hydrates it over that markup,
and returns every disagreement. Each pass calls view inside its own
owner, so the effects and onDispose cleanups a component registers end
before the helper returns. An empty array means the component hydrates
cleanly; the container is discarded afterwards.
Source: packages/test/src/index.ts:133
accessibilityIssues
function accessibilityIssues(container: ParentNode): AccessibilityIssue[]Finds the defects that need no accessibility tree to detect, the ones the
WebAIM Million finds on most home pages: images without alt, form
controls without a label, buttons and links without an accessible name,
and frames without a title. It is a floor, not a conformance check.
Source: packages/test/src/index.ts:205
Interfaces
Mounted
interface MountedWhat mount returns.
readonly container: HTMLElement: The element the view was rendered into.readonly root: Root: The rootrenderreturned for the view;unmountdisposes it.unmount(): void: Disposes the view and removes the container;cleanupdoes the same for every mount.
Source: packages/test/src/index.ts:10
MountOptions
interface MountOptionsOptions for mount.
container?: HTMLElement: Renders into this element instead of a newdiv.attach?: boolean: Appends a new container todocument.body. Defaults to true; layout and focus need it. Ignored withcontainer.
Source: packages/test/src/index.ts:21
AccessibilityIssue
interface AccessibilityIssueOne defect found by accessibilityIssues.
readonly code: AccessibilityCode: Which check the element failed, such asimage_without_alt.readonly element: Element: The element that failed the check, found inside the container passed toaccessibilityIssues.
Source: packages/test/src/index.ts:147
Types
AccessibilityCode
type AccessibilityCode = "image_without_alt" | "control_without_label" | "button_without_name" | "link_without_name" | "frame_without_title"The accessibility checks accessibilityIssues runs.
Source: packages/test/src/index.ts:144