Skip to content
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

fix(msw): make sure to not try to include error type in mock implementation #1274

Merged

Conversation

AllieJonsson
Copy link
Contributor

Status

READY

Description

Fixes #1273
Mock tried to import the error type, which caused the non-mock implementation to not try and import it. The mock code then filtered out all imports that weren't used in the mock, thus leaving out the error type.

Todos

  • Tests
  • Documentation
  • Changelog Entry (unreleased)

Steps to Test or Reproduce

  1. cd tests
  2. yarn generate:swr
  3. go to generated/swr/petstore/endpoints.ts
  4. see that the Error type is the generated Error model, and not the default js Error
export type ListPetsQueryError = AxiosError<Error>
//                                            ^ Go to definition leads to generated Error model
  1. compare to previous version, where go to definition leads you to default js Error type.

@melloware melloware added bug Something isn't working mock Related to mock generation and removed bug Something isn't working labels Mar 20, 2024
@melloware melloware added this to the 6.26.0 milestone Mar 20, 2024
@melloware
Copy link
Collaborator

melloware commented Mar 20, 2024

Looks like the tests are failing?

Actually its just a formatting issue please run the format command in the package.json.

@AllieJonsson AllieJonsson force-pushed the fix/include-custom-error-type branch from 04aea96 to 34113b2 Compare March 20, 2024 15:11
@melloware melloware merged commit 5fe09c3 into orval-labs:master Mar 20, 2024
2 checks passed
@AllieJonsson AllieJonsson deleted the fix/include-custom-error-type branch March 20, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mock Related to mock generation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SWR/React Query: Custom error type model is not imported when mock: true
2 participants