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

Support MSW response override #961

Closed
karlismelderis-mckinsey opened this issue Apr 26, 2024 · 1 comment
Closed

Support MSW response override #961

karlismelderis-mckinsey opened this issue Apr 26, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@karlismelderis-mckinsey

What is the problem this feature would solve?

add support

  • to provide response faker overrides in MSW generated code
  • to mock error responses

External documents/projects?

No response

What is the feature you are proposing to solve the problem?

Faker already supports an option to specify overrides
Would be cool if it would be possible to provide overrides in MSW code as well

import { http, HttpResponse } from 'msw';

export const requestHandler = (data: Parameters<typeof createMutationResponse>) => http.put(
  '*/...',
  function handler(info) {
    return HttpResponse.json(
      createMutationResponse(data),
      {
        status: 200,
      },
    );
  },
);

Also I didn't see how to mock error responses with kubb library
e.g. 404 and 400

What alternatives have you considered?

No response

@karlismelderis-mckinsey karlismelderis-mckinsey added the enhancement New feature or request label Apr 26, 2024
@stijnvanhulle
Copy link
Collaborator

For this, you can use the templates and create your own function that will pass through data. I can provide you with an example of how you can achieve this but right now we are not planning to add this as the default to Kubb.

Something we can change in v3 of Kubb if more people wants this as the default.

@stijnvanhulle stijnvanhulle closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants