We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Currently, a msw mock handler would be:
import { HttpResponse, HttpResponseResolver, delay, http } from 'msw' export const getSomethingMockHandler = (overrideResponse?: SomethingResponse) => { return http.get('/something', async () => { await delay(1000); return new HttpResponse(JSON.stringify(overrideResponse ? overrideResponse : getSomethingResponseMock()), { status: 200, headers: { 'Content-Type': 'application/json', } } ) }) }
But it would be nice if overrideResponse is a function. So that we can produce response programmatically.
export const getSomethingMockHandler = (overrideResponse?: (resolver: HttpResponseResolver) => SomethingResponse | Promise<SomethingResponse>) => { return http.get('/something', async (resolver) => { await delay(1000); const response = overrideResponse ? overrideResponse(resolver) : getSomethingResponseMock() return new HttpResponse(JSON.stringify(response)), { status: 200, headers: { 'Content-Type': 'application/json', } } ) }) }
The text was updated successfully, but these errors were encountered:
@soartec-lab is this the same issue you just fixed in 6.28.0? #1293
Sorry, something went wrong.
@melloware No, this is separate from #1293. I'll add an enhancement label to this.
Successfully merging a pull request may close this issue.
Currently, a msw mock handler would be:
But it would be nice if overrideResponse is a function. So that we can produce response programmatically.
The text was updated successfully, but these errors were encountered: