Skip to content

Error Testing Overview

The Sparkle error testing framework provides a fluent API for creating comprehensive error scenarios and validation tests.

Create type-safe error scenarios using the fluent builder pattern:

import { TestScenarioBuilder } from '@sparkle/error-testing'
const scenario = TestScenarioBuilder
.create<ValidationError, FormState>('Email validation')
.withErrorType('VALIDATION_ERROR')
.withState({ email: 'invalid-email' })
.build()

Common error testing patterns:

  • Validation Errors - Form and input validation
  • Network Errors - API and connectivity issues
  • Authentication Errors - Login and permission failures
  • Runtime Errors - Unexpected application errors
  • Use descriptive scenario names
  • Test both error and success paths
  • Leverage TypeScript for type safety
  • Group related scenarios together