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

test: describe network using only msw #711

Merged
merged 22 commits into from
Mar 25, 2024
Merged

test: describe network using only msw #711

merged 22 commits into from
Mar 25, 2024

Conversation

juliusmarminge
Copy link
Collaborator

trying to get rid of our mockExternalRequest(db) in favor of only using msw to describe all the external requests, no matter if the method accepts a fetch override or not.

it's going.... well not so good 😓

Copy link

changeset-bot bot commented Mar 15, 2024

⚠️ No Changeset found

Latest commit: 3eac0e5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Mar 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs-uploadthing ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 24, 2024 11:40am

Copy link
Collaborator Author

@juliusmarminge juliusmarminge Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this here fixes some incompatabilities with using happy-dom. Somewhere some serialization is failing which results in a new URL("[object Request]") which (obviously) fails. this patch seems to fix it

}
this.logger.info("no mocked response received!");
- return pureFetch(request).then((response) => {
+ return pureFetch(resolvedInput, init).then((response) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. The request is created by taking init into account:

https://github.com/mswjs/interceptors/blob/b1bc5a5adf31726996d0935aa4b178eade1f9ac5/src/interceptors/fetch/index.ts#L50

Can you tell me more about how you reproduce this issue? Would love to make a regression test out of it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something with happy-dom when it's creating the url object for the request. seems like something doesn't get serialized as i debugged it was calling the URL constructor with the string [object Request] resulting in a Invalid URL error

Copy link
Contributor

@kettanaito kettanaito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks much better now! Great job, @juliusmarminge. I've left a few comments on how you can improve MSW usage even further. Give those a read.

juliusmarminge and others added 3 commits March 24, 2024 09:57
Co-authored-by: Artem Zakharchenko <[email protected]>
Co-authored-by: Artem Zakharchenko <[email protected]>
Co-authored-by: Artem Zakharchenko <[email protected]>
@juliusmarminge juliusmarminge merged commit 020874a into main Mar 25, 2024
10 checks passed
@kettanaito
Copy link
Contributor

🚀

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.

2 participants