API Reference
Sparkle Design System API / error-testing/src
error-testing/src
Section titled “error-testing/src”Classes
Section titled “Classes”TestScenarioBuilder
Section titled “TestScenarioBuilder”A fluent builder for creating type-safe error test scenarios.
Type Parameters
Section titled “Type Parameters”TError
Section titled “TError”TError extends Error = Error
TState
Section titled “TState”TState = unknown
Methods
Section titled “Methods”build()
Section titled “build()”build():
TestScenarioConfig<TError,TState>
Builds the test scenario configuration.
Returns
Section titled “Returns”TestScenarioConfig<TError, TState>
Throws
Section titled “Throws”If the configuration is incomplete
execute()
Section titled “execute()”execute(
context):Promise<TestResult<TError>>
Executes the test scenario.
Parameters
Section titled “Parameters”context
Section titled “context”TestContext<TState>
The test context
Returns
Section titled “Returns”Promise<TestResult<TError>>
withDescription()
Section titled “withDescription()”withDescription(
description):this
Sets the description for the test scenario.
Parameters
Section titled “Parameters”description
Section titled “description”string
Returns
Section titled “Returns”this
withErrorType()
Section titled “withErrorType()”withErrorType<
E>(errorType):TestScenarioBuilder<E,TState>
Specifies the error type to test.
Type Parameters
Section titled “Type Parameters”E extends Error
Parameters
Section titled “Parameters”errorType
Section titled “errorType”Object
The constructor for the error type
Returns
Section titled “Returns”TestScenarioBuilder<E, TState>
withRecovery()
Section titled “withRecovery()”withRecovery(
recovery):this
Adds a recovery strategy to the test scenario.
Parameters
Section titled “Parameters”recovery
Section titled “recovery”ErrorRecoveryStrategy<TError, TState>
The recovery strategy to use
Returns
Section titled “Returns”this
withSetup()
Section titled “withSetup()”withSetup(
setup):this
Adds a setup function to the test scenario.
Parameters
Section titled “Parameters”(context) => Promise<void>
The setup function to run before the test
Returns
Section titled “Returns”this
withTeardown()
Section titled “withTeardown()”withTeardown(
teardown):this
Adds a teardown function to the test scenario.
Parameters
Section titled “Parameters”teardown
Section titled “teardown”(context) => Promise<void>
The teardown function to run after the test
Returns
Section titled “Returns”this
create()
Section titled “create()”
staticcreate<E,S>(description):TestScenarioBuilder<E,S>
Creates a new test scenario builder.
Type Parameters
Section titled “Type Parameters”E extends Error = Error
S = unknown
Parameters
Section titled “Parameters”description
Section titled “description”string
A description of the test scenario
Returns
Section titled “Returns”TestScenarioBuilder<E, S>
Interfaces
Section titled “Interfaces”ErrorBoundaryConfig
Section titled “ErrorBoundaryConfig”Base interface for error boundary configurations.
Type Parameters
Section titled “Type Parameters”TError
Section titled “TError”TError extends Error = Error
ErrorRecoveryStrategy
Section titled “ErrorRecoveryStrategy”Type-safe error recovery strategy.
Type Parameters
Section titled “Type Parameters”TError
Section titled “TError”TError extends Error = Error
TState
Section titled “TState”TState = unknown
TestContext
Section titled “TestContext”Represents a test scenario context that maintains type safety throughout the test lifecycle.
Type Parameters
Section titled “Type Parameters”TState
Section titled “TState”TState = unknown
TestResult
Section titled “TestResult”Result of a test scenario execution.
Type Parameters
Section titled “Type Parameters”TError
Section titled “TError”TError extends Error = Error
TestScenarioConfig
Section titled “TestScenarioConfig”Configuration for a test scenario.
Type Parameters
Section titled “Type Parameters”TError
Section titled “TError”TError extends Error = Error
TState
Section titled “TState”TState = unknown