Skip to content

[Testing] Create comprehensive test helpers for ESM mock patterns #271

Description

@devin-ai-integration

Domain: Testing


Issue [Feature] Create comprehensive test helpers for ESM mock patterns

Tier: 🟡 Medium

Description:

  • Problem: Multiple test files independently define the same mock objects for stellar.service.js, users.model.js, telemetry.model.js, infra/socket/io.js, etc. Each mock must include ALL named exports from the real module or ESM resolution fails. This has caused 48+ test failures across the suite because individual test files forget to include exports like getStellarExplorerUrl, UserRole, Telemetry, or bulkIngestTelemetry.
  • Implementation: Create a tests/helpers/mocks.ts file that exports complete, reusable mock factories:
    • createStellarServiceMock() — returns all 4 exports
    • createUsersModelMock() — returns UserModel, OrganizationModel, UserRole, OrganizationType
    • createTelemetryModelMock() — returns Telemetry, TelemetryAnchorStatus
    • createSocketIoMock() — returns all 5 socket functions
      Each factory returns a complete mock object. Test files import and use these factories, ensuring no exports are forgotten.

Dependencies:

  • Depends on None

Acceptance Criteria:

  • tests/helpers/mocks.ts exports factory functions for all commonly-mocked modules.
  • Each factory returns ALL named exports from the real module.
  • At least 3 test files are migrated to use the helpers as examples.
  • Documentation in the helpers file explains the pattern.

Testing Requirements:

  • All migrated test files pass with the new helpers.
  • Run npm test to confirm no regressions.

PR Checklist:

  • Branch is named conventionally (e.g., feature/issue-XX-test-mock-helpers).
  • npm run lint and npm run build pass with zero warnings.
  • Screenshot of passing Jest terminal logs is attached to the PR.

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave program

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