Skip to content

Conversation

@pd-redis
Copy link
Collaborator

This pull request focuses on updating the MSW (Mock Service Worker) API usage throughout the codebase. It also upgrades related dependencies and adjusts the Jest configuration to support these changes.

MSW API Modernization and Type Cleanup:

  • update MSW version

  • updated calls to follow current API of MSW

Dependency and Jest Configuration Updates:

  • Upgraded msw to version ^2.11.5 and added jest-fixed-jsdom

  • Changed Jest configuration to use jest-fixed-jsdom as the test environment, added until-async to the transformIgnorePatterns, and included customExportConditions in testEnvironmentOptions. All of this is to support MSW 2 with jestdom

Code Cleanup:

  • Removed unused re-export of FormField in FormField.ts.

const handlers: HttpHandler[] = [
// useGetClusterDetailsQuery
rest.get<DatabaseInstanceResponse[]>(
http.get<any, DatabaseInstanceResponse[]>(
Copy link
Member

@valkirilov valkirilov Oct 17, 2025

Choose a reason for hiding this comment

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

Looking at the http.get call, I'm a bit confused about the generic types. From what I understand about MSW's type signature, the generics are <PathParams, ResponseBodyType, RequestBodyType>. So:

  1. Path params (any)
    Since we're not using any path parameters in this URL pattern, could we use Record<string, never> or just omit it instead of any?

  2. Response body type (DatabaseInstanceResponse[])
    We're actually returning CLUSTER_DETAILS_DATA_MOCK which is typed as ClusterDetails (a single object, not an array). Shouldn't this be:

    http.get<Record<string, never>, ClusterDetails>(...)

Or the ClusterDetails interface is actually a subset of DatabaseInstanceResponse, and it's fine.

  1. General question
    When I remove these type parameters entirely, I don't see any TypeScript errors. Are these types actually being validated somewhere, or are they more for documentation purposes? Maybe I'm missing some context about how MSW uses these in the testing setup?

I'm just trying to make sure I understand the pattern correctly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

since this is purely test code, and TS types have no effect on actual results, I am in favor of omitting them overall

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.

3 participants