-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
feat(ct): expose msw
fixture that accepts msw-style request handlers
#31154
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
Implemented on top of `context.route()`.
Test results for "tests 1"15 passed Merge workflow run. |
} | ||
} | ||
|
||
async function globalFetch(...args: Parameters<typeof globalThis.fetch>) { |
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.
If you add msw
as a dependency, it exposes the getResponse
function that you can reuse here. Less logic duplication.
run(args: { request: Request, resolutionContext: { baseUrl?: string }, requestId: string }): Promise<{ response: Response } | undefined>; | ||
} | ||
|
||
export interface MSW { |
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.
Would be nice to actually import { RequestHandler } from 'msw'
.
I have some concerns about this. Please see #30981. TL;DR I'd rather people used the same MSW experience than a compatible API. MSW works great in any browser, including browsers automated by Playwright. I see no reason to diverge the behavior, losing a significant chunk of MSW's benefits along the way. |
Implemented on top of
context.route()
.