Skip to content

feat(sdk): add integration tests and standardize ApiError handling#267

Merged
Xhristin3 merged 1 commit into
XStreamRollz:mainfrom
Meet-hybrid:fix/sdk-integration-tests
Jun 16, 2026
Merged

feat(sdk): add integration tests and standardize ApiError handling#267
Xhristin3 merged 1 commit into
XStreamRollz:mainfrom
Meet-hybrid:fix/sdk-integration-tests

Conversation

@Meet-hybrid

Copy link
Copy Markdown
Contributor

Description
This PR addresses the lack of automated verification for the SDK's actual HTTP communication. Previously, tests only
covered configuration resolution. This update introduces integration tests using nock and standardizes error handling
by ensuring all failed requests throw the SDK-native ApiError instead of raw AxiosError.

Changes

  • Core Improvements:
    • Modified StreamingClient to include a response interceptor that intercepts AxiosError and wraps them into
      ApiError.
    • Integrated ApiErrorResponse parsing to provide meaningful error messages from the API.
  • Testing Enhancements:
    • Added nock as a development dependency in the xstreamroll-sdk package.
    • Created client.integration.test.ts to verify the full lifecycle of SDK operations:
      • Authentication: Validated login, register, and logout.
      • Stream Events: Verified request body structure and headers for publishEvent.
      • Resiliency: Confirmed automatic token refresh and retry logic on 401 Unauthorized responses.
      • Error Handling: Verified that failed requests throw the expected ApiError.

Impact

  • Reliability: Confirms that the SDK correctly interacts with the API endpoints.
  • Developer Experience: Provides consistent error handling for SDK consumers, allowing them to use instanceof
    ApiError to catch and handle API-specific failures.
  • Maintenance: Protects against regressions in auth interceptors and retry logic.

Verification Results
Ran npm test in the xstreamroll-sdk directory:

  • Total Test Suites: 4 passed
  • Total Tests: 26 passed (7 new integration tests, 19 existing unit tests)

1 PASS tests/client.integration.test.ts
2 PASS tests/http.test.ts
3 PASS tests/client.test.ts
4 PASS tests/retry.test.ts

Fixes
Closes #224

@Xhristin3 Xhristin3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @Meet-hybrid! The response interceptor wrapping AxiosErrors into ApiError is exactly what the SDK needed — instanceof ApiError will make error handling much cleaner for consumers. The nock-based integration tests are comprehensive: auth flow (login, register, logout), stream operations with body verification, and a full 401 auto-refresh retry cycle. 26 tests all passing. Closes #224. 🚀

@Xhristin3 Xhristin3 merged commit 6893143 into XStreamRollz:main Jun 16, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: Add SDK integration test with real API

2 participants