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

[Feature] Mock response status and headers #7

Merged
merged 6 commits into from
Sep 2, 2024

Conversation

DRFR0ST
Copy link
Owner

@DRFR0ST DRFR0ST commented Aug 5, 2024

This PR will allow mocking the response status and headers.

@DRFR0ST DRFR0ST added the enhancement New feature or request label Aug 5, 2024
@DRFR0ST DRFR0ST self-assigned this Aug 5, 2024
@DRFR0ST DRFR0ST linked an issue Aug 10, 2024 that may be closed by this pull request
@@ -3,7 +3,19 @@
* Partial implementation of RequestInit with the addition of "data" property which value will be returned from the mock.
*/
export type MockOptions = {
/** @deprecated use response.data */
Copy link
Owner Author

Choose a reason for hiding this comment

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

I don't feel confidend deprecating the root data property and using the response.data instead.
It's logically correct to have the data inside the response object, as it de facto mocks the response body, but it also gets rid of the simplicity of mock('..', { data: {...} }).
On the other hand, keeping both seems unnecessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think having two ways to do such a same thing is a good idea, I find it unnecessary and confusing. I would suggest deprecating it.

@DRFR0ST DRFR0ST marked this pull request as ready for review August 31, 2024 09:28
Repository owner deleted a comment from github-actions bot Aug 31, 2024
Repository owner deleted a comment from github-actions bot Aug 31, 2024
Repository owner deleted a comment from github-actions bot Aug 31, 2024
Repository owner deleted a comment from github-actions bot Aug 31, 2024
Repository owner deleted a comment from github-actions bot Aug 31, 2024
Repository owner deleted a comment from github-actions bot Aug 31, 2024
@DRFR0ST DRFR0ST merged commit 3793f82 into main Sep 2, 2024
1 check passed
@DRFR0ST DRFR0ST deleted the feature/mock-response-status branch September 2, 2024 16:32
@brianorwhatever
Copy link

Can you please make a release with this PR merged?

@sadkebab
Copy link
Contributor

I am waiting for this to be released too

@brianorwhatever
Copy link

@sadkebab I've added the dist folder to this fork temporarily as I wait for this release https://github.com/brianorwhatever/bun-bagel

@DRFR0ST
Copy link
Owner Author

DRFR0ST commented Sep 22, 2024

Sorry for the delay! Released 🚀

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

Successfully merging this pull request may close these issues.

Add ability to mock status codes
3 participants