-
-
Notifications
You must be signed in to change notification settings - Fork 347
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(msw): possible to overwrite value when creating an object
with msw
mock
#1165
feat(msw): possible to overwrite value when creating an object
with msw
mock
#1165
Conversation
@Will-Mann-16 can you review since you recently did a lot of work in Mock? |
object
with msw
mockobject
with msw
mock
@Will-Mann-16 |
It looks good to me if @Will-Mann-16 has an issue we can re-open. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the only thing I saw - if it's tested and works I'm happy. Otherwise might need a separate issue but would be an easy fix.
@@ -80,7 +82,7 @@ export const generateMSW = ( | |||
implementation: { | |||
function: | |||
value && value !== 'undefined' | |||
? `export const ${functionName} = () => (${value})\n\n` | |||
? `export const ${functionName} = (${isResponseOverridable ? `overrideResponse?: any` : ''}) => (${value})\n\n` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some ESLint config setups would throw errors if you try to spread an undefined value, is it worth setting this to a default param of {}
, empty object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your comment. That's good. I didn't have that perspective. I'll fix it in another PR.
Status
READY
Description
I responded to part of #822
If there is only one response case and the type is
object
, the returned value can be overwritten externally by specifyingoverrideResponse
as an argument.In order to handle the case where it is an
array
ofobject
such asPets
, after calculating the return value, we determine whether overwriting is possible based on whetheroverrideResponse
is included in it.Todos
Steps to Test or Reproduce
orval