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

feat(ct): expose msw fixture that accepts msw-style request handlers #31154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dgozman
Copy link
Contributor

@dgozman dgozman commented Jun 4, 2024

Implemented on top of context.route().

This comment has been minimized.

docs/src/test-components-js.md Outdated Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Jun 5, 2024

Test results for "tests 1"

15 passed
✔️✔️✔️

Merge workflow run.

}
}

async function globalFetch(...args: Parameters<typeof globalThis.fetch>) {

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 {

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'.

@kettanaito
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants