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

fix: Ensure Response#mode is 'cors' when Request#type is 'cors' #60

Merged
merged 1 commit into from
Feb 20, 2025

Conversation

nzakas
Copy link
Contributor

@nzakas nzakas commented Feb 20, 2025

This pull request ensures that the Response#mode property is properly set to "cors" when the type property of the Request is set to "cors". This also ensures that the default Response#mode is "cors" per the Fetch API specification (Bun sets it to "default".

The most important changes include setting the mode property correctly in the createCustomRequest function, updating the FetchMocker class to set response properties, and modifying the MockServer tests to validate response status and type.

Replaces and closes #57.

Improvements to fetch API handling:

  • src/custom-request.js: Added logic to set the mode property to "cors" by default if not specified, ensuring consistency across different runtimes.
  • src/fetch-mocker.js: Updated the FetchMocker class to set the url and type properties of the response based on the request's mode.

Updates to test cases:

@nzakas nzakas merged commit 910bc87 into main Feb 20, 2025
12 checks passed
@nzakas nzakas deleted the cors-response-type branch February 20, 2025 18:30
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.

1 participant