Skip to content

API Reference

Sparkle Design System API


Sparkle Design System API / error-testing/src

A fluent builder for creating type-safe error test scenarios.

TError extends Error = Error

TState = unknown

build(): TestScenarioConfig<TError, TState>

Builds the test scenario configuration.

TestScenarioConfig<TError, TState>

If the configuration is incomplete

execute(context): Promise<TestResult<TError>>

Executes the test scenario.

TestContext<TState>

The test context

Promise<TestResult<TError>>

withDescription(description): this

Sets the description for the test scenario.

string

this

withErrorType<E>(errorType): TestScenarioBuilder<E, TState>

Specifies the error type to test.

E extends Error

Object

The constructor for the error type

TestScenarioBuilder<E, TState>

withRecovery(recovery): this

Adds a recovery strategy to the test scenario.

ErrorRecoveryStrategy<TError, TState>

The recovery strategy to use

this

withSetup(setup): this

Adds a setup function to the test scenario.

(context) => Promise<void>

The setup function to run before the test

this

withTeardown(teardown): this

Adds a teardown function to the test scenario.

(context) => Promise<void>

The teardown function to run after the test

this

static create<E, S>(description): TestScenarioBuilder<E, S>

Creates a new test scenario builder.

E extends Error = Error

S = unknown

string

A description of the test scenario

TestScenarioBuilder<E, S>

Base interface for error boundary configurations.

TError extends Error = Error


Type-safe error recovery strategy.

TError extends Error = Error

TState = unknown


Represents a test scenario context that maintains type safety throughout the test lifecycle.

TState = unknown


Result of a test scenario execution.

TError extends Error = Error


Configuration for a test scenario.

TError extends Error = Error

TState = unknown