Skip to content

Build comprehensive mock factory for SDK testing #379

Description

@Kingsman-99

Overview

Apps using the SDK have no official way to mock it in unit tests, leading to either real RPC calls in tests or hand-rolled mocks that drift from the real API. Publish an official mock factory.

Acceptance Criteria

  • @stellar-split/sdk/testing sub-package export with zero production dependencies
  • createMockSdk(overrides?) returns a fully-typed mock of StellarSplitSDK with jest/vitest spy functions
  • Default return values for all read methods (sensible stub Invoice, LeaderboardEntry[], etc.)
  • overrides allows partial replacement: createMockSdk({ getInvoice: async () => myInvoice })
  • mockSdk.getInvoice.mockResolvedValueOnce(...) pattern works (jest-compatible)
  • Mock includes __state helpers: mockSdk.__state.setInvoice(id, invoice) for scenario setup
  • Type-safe: TypeScript will error if an override returns the wrong type
  • Usage examples in README.md covering the most common test patterns

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions