@askrjs/askr/testing
Exports from the declarations published in @askrjs/askr. Signatures reflect the published artifact.
Exports
This entrypoint publishes 29 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.
cleanuptype
cleanup: (target: RenderResult | HTMLElement) => voidTear down a test render, given either its {@link RenderResult} or container element.
clicktype
click: (element: Element) => booleanDispatch the browser click sequence expected by Askr's delegated events.
createInvalidationRecordertype
createInvalidationRecorder: () => InvalidationRecorderStart recording {@link invalidate } calls for assertions; call `stop()` when done.
createMutationTestRegistrytype
createMutationTestRegistry: () => MutationTestRegistryCreate a keyed mutation fixture registry for a test render runtime.
createQueryTestRegistrytype
createQueryTestRegistry: () => QueryTestRegistryCreate a keyed query fixture registry for a test render runtime.
dispatchtype
dispatch: (target: EventTarget, event: Event | string, init?: DispatchEventInit) => booleanDispatch an event (constructed from a type string, or given directly) on `target`.
flushtype
flush: () => voidSynchronously flush the runtime's scheduled work (renders, effects).
getRouteWarningstype
getRouteWarnings: (options: MatchRouteOptions) => RoutePatternWarning[]Find named-splat routes whose reserved segments collide with sibling static routes.
InvalidationRecordtype
InvalidationRecord: anyA single recorded call to {@link invalidate }, captured by {@link createInvalidationRecorder}.
prefix- prefix: string;
markPendingWrite- markPendingWrite: boolean;
InvalidationRecordertype
InvalidationRecorder: anyRecorder returned by {@link createInvalidationRecorder}.
calls- readonly calls: readonly InvalidationRecord[];
prefixes- readonly prefixes: readonly string[];
clear- clear(): void;
stop- stop(): void;
matchRoutetype
matchRoute: (path: string, options: MatchRouteOptions) => RouteMatch | nullMatch `path` against a route registry for tests, without mounting the app.
mockQuerytype
mockQuery: (<T extends {}>(data: T, options?: MockQueryOptions) => Query<T>) & { loading<T extends {} = {}>(options?: MockQueryOptions): Query<T>; error<T extends {} = {}>(error: {}, previousData?: T, options?: MockQueryOptions): Query<T>; refreshing<T extends {}>(data: T, options?: MockQueryOptions): Query<T>; stale<T extends {}>(data: T, reason?: StaleValueReason, options?: MockQueryOptions): Query<T>; pendingWrite<T extends {}>(data: T, options?: MockQueryOptions): Query<T>; }Build a fresh {@link Query} fixture for tests: call directly with data, or use `.loading()`/`.error()`/`.refreshing()`/`.stale()`/`.pendingWrite()`.
MockQueryOptionstype
MockQueryOptions: anyOptions for {@link mockQuery} fixtures.
refresh- refresh?: MockRefresh;
MockRefreshtype
MockRefresh: () => void | Promise<void>Refresh callback for a {@link mockQuery} fixture, invoked by the query's `refresh()`.
mounttype
mount: (component: ComponentFunction, options?: RenderOptions) => RenderResultAlias for {@link render}.
MutationFixturetype
MutationFixture: Mutation<TInput, TResult> & {
/** Inputs received by the fixture's execute method. */
readonly inputs: readonly TInput[];
/** Move the fixture to pending without starting application work. */
setPending(): void;
/** Resolve the current fixture execution and expose its result. */
succeed(result: TResult): void;
/** Reject the current fixture execution and expose its error. */
fail(error: {}): void;
}A {@link Mutation} whose state is driven manually via `setPending`/`succeed`/`fail`.
MutationFixtureInitialtype
MutationFixtureInitial: {
pending?: boolean;
error?: {} | null;
result?: TResult;
}Initial state for {@link mutationState}; exactly one of `pending`/`error`/`result` may be set.
mutationStatetype
mutationState: (<TInput = unknown, TResult = unknown>(initial?: MutationFixtureInitial<TResult>) => MutationFixture<TInput, TResult>) & { idle<TInput = unknown, TResult = unknown>(): MutationFixture<TInput, TResult>; pending<TInput = unknown, TResult = unknown>(): MutationFixture<TInput, TResult>; success<TInput = unknown, TResult = unknown>(result: TResult): MutationFixture<TInput, TResult>; error<TInput = unknown, TResult = unknown>(error: {}): MutationFixture<TInput, TResult>; }Build a {@link MutationFixture} for tests: call directly with initial state, or use `.idle()`/`.pending()`/`.success(result)`/`.error(error)`.
MutationTestRegistrytype
MutationTestRegistry: anyKeyed mutation fixture registry returned by {@link createMutationTestRegistry}.
runtime- readonly runtime: DataRuntime;
set- set<TInput, TResult>(key: string, mutation: Mutation<TInput, TResult>): void;
delete- delete(key: string): void;
clear- clear(): void;
queryStatetype
queryState: { fresh: typeof createFreshQuery; loading: <T extends {} = {}>(options?: MockQueryOptions) => Query<T>; error: <T extends {} = {}>(error: {}, previousData?: T, options?: MockQueryOptions) => Query<T>; refreshing: <T extends {}>(data: T, options?: MockQueryOptions) => Query<T>; stale: <T extends {}>(data: T, reason?: StaleValueReason, options?: MockQueryOptions) => Query<T>; pendingWrite: <T extends {}>(data: T, options?: MockQueryOptions) => Query<T>; }Alias table mirroring {@link mockQuery}'s state builders (`fresh`, `loading`, `error`, ...).
QueryTestRegistrytype
QueryTestRegistry: anyKeyed query fixture registry returned by {@link createQueryTestRegistry}.
runtime- readonly runtime: DataRuntime;
set- set<T extends {}>(key: string, query: Query<T>): void;
delete- delete(key: string): void;
clear- clear(): void;
rendertype
render: (component: ComponentFunction, options?: RenderOptions) => RenderResultMount `component` as an island into a test container and flush pending work.
RenderOptionstype
RenderOptions: anyOptions for {@link render} and {@link mount}.
container- Existing element to own for the duration of the render. When omitted, the harness appends a managed `<div>` to `document.body`.
cleanupStrict- Surface lifecycle cleanup errors during unmount.
RenderResulttype
RenderResult: anyHandle to a mounted test render, returned by {@link render}/{@link mount}/{@link renderRoute}.
container- readonly container: HTMLElement;
root- readonly root: HTMLElement;
flush- flush(): void;
dispatch- dispatch(target: EventTarget, event: Event | string, init?: DispatchEventInit): boolean;
unmount- unmount(): void;
cleanup- cleanup(): void;
renderRoutetype
renderRoute: (options: RouteRenderOptions) => Promise<RenderResult>Mount a routed app (via {@link createSPA }) into a test container for the given route registry.
RoutePatternWarningtype
RoutePatternWarning: anyA splat-route/static-route path collision reported by {@link getRouteWarnings}.
kind- kind: 'route-collision';
path- path: string;
conflictingPath- conflictingPath: string;
segment- segment: string;
namespace- namespace: string | undefined;
message- message: string;
RouteRenderOptionstype
RouteRenderOptions: anyOptions for {@link renderRoute}.
registry- registry: RouteRegistry;
url- Initial path, query, and hash for the routed render.
auth- auth?: RouteAuthOptions;
dataRuntime- dataRuntime?: DataRuntime;
submittype
submit: (form: HTMLFormElement) => booleanDispatch a cancelable bubbling submit event on a form.
typetype
type: (element: HTMLInputElement | HTMLTextAreaElement, text: string) => voidSet a text control's value and emit an input event for each character.