-
Notifications
You must be signed in to change notification settings - Fork 410
fix test runner #5069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: playground
Are you sure you want to change the base?
fix test runner #5069
Conversation
| const handlers: HttpHandler[] = [ | ||
| // useGetClusterDetailsQuery | ||
| rest.get<DatabaseInstanceResponse[]>( | ||
| http.get<any, DatabaseInstanceResponse[]>( |
There was a problem hiding this comment.
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:
-
Path params (
any)
Since we're not using any path parameters in this URL pattern, could we useRecord<string, never>or just omit it instead ofany? -
Response body type (
DatabaseInstanceResponse[])
We're actually returningCLUSTER_DETAILS_DATA_MOCKwhich is typed asClusterDetails(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.
- 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.
There was a problem hiding this comment.
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
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
mswto version^2.11.5and addedjest-fixed-jsdomChanged Jest configuration to use
jest-fixed-jsdomas the test environment, addeduntil-asyncto thetransformIgnorePatterns, and includedcustomExportConditionsintestEnvironmentOptions. All of this is to support MSW 2 with jestdomCode Cleanup:
FormFieldinFormField.ts.