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: allow any defined response value #214

Conversation

prichey
Copy link

@prichey prichey commented Jul 9, 2024

The response validator as written fails for valid JSON (e.g. null, "foo", true, etc.). If the validator is going to enforce valid JSON, it should allow all JSON values, not just some. Furthermore, in my opinion this package shouldn't be concerned with validating a user-provided response, perhaps other than asserting that it is defined. Some APIs return invalid JSON - this package should support mocking those, too.

My changes here relax the response validation to merely asserting that it is not undefined. One could argue that undefined should be allowed too, but in this PR I'm only interested in permitting any defined value.

This PR would supersede #201 and close #200

Copy link

netlify bot commented Jul 9, 2024

Deploy Preview for storybook-addon-mock ready!

Name Link
🔨 Latest commit b80aafc
🔍 Latest deploy log https://app.netlify.com/sites/storybook-addon-mock/deploys/668d4b7a0faead000802049c
😎 Deploy Preview https://deploy-preview-214--storybook-addon-mock.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@prichey prichey changed the title Allow any defined response value feat: allow any defined response value Jul 10, 2024
@prichey
Copy link
Author

prichey commented Aug 29, 2024

For posterity: msw-storybook-addon supports this and is regularly maintained

@prichey prichey closed this Oct 10, 2024
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.

Support string responses
1 participant