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

Add MockedResponse -> newData to docs #205

Open
wild-lotus opened this issue Jan 10, 2020 · 5 comments
Open

Add MockedResponse -> newData to docs #205

wild-lotus opened this issue Jan 10, 2020 · 5 comments
Labels
documentation project-apollo-client (legacy) LEGACY TAG DO NOT USE 🧪 testing Feature requests related to testing

Comments

@wild-lotus
Copy link

I just realised that when providing a MockedResponse to MockedProvider, you can provide a newData key in the MockedResponse. This seems to be an alternative to the result key.
I have found no documentation about it.

My request here is to add this newData to MockedProvider docs.

On top of that, if you could leave here a brief explanation of the differences between newData and result for the meantime, I would appreciate.

@stuartjbrown
Copy link

I'd also like some info about this newData - could you find something out @CarlosGines ? Or can someone else give more info? Thanks!

@artium-ryanh
Copy link

I've seen this addition requested here and on other websites and people have been requesting it for years. I just want to say it's super inconvenient that it hasn't been added to the docs yet. So far, all I can gather about newData is that it's a function run to get maybe data for successive calls but not the first one? I have no idea how it's different from result being a function.

@bignimbus
Copy link
Contributor

Hi @artium-ryanh @stuartjbrown @CarlosGines 👋🏻 newData lets users control the mocked response result dynamically in case they want to test scenarios with responses that can't be statically defined. Here's an SO thread showing a real-world usage. And here's a blog post by @jkettmann that goes into some depth about how they used newData for mutation testing. I agree this should be in the docs - not sure when the maintainers will get to it but I hope this info is enough to go on for now. And if you're interested in submitting a PR we'd definitely be interested in reviewing it!

@artium-ryanh
Copy link

@bignimbus It does help, thank you! I was able to figure that out with experimentation and I'm glad to know this post can be a resource for people searching for the same thing I was. I'd consider drafting a PR, but I'm not sure where I would make it. Can you link me to the docs repo?

@bignimbus
Copy link
Contributor

@artium-ryanh awesome 🚀 I think this file would probably be a good place to start: https://github.com/apollographql/apollo-client/blob/main/docs/source/development-testing/testing.mdx

@jerelmiller jerelmiller added 🧪 testing Feature requests related to testing documentation labels Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation project-apollo-client (legacy) LEGACY TAG DO NOT USE 🧪 testing Feature requests related to testing
Projects
None yet
Development

No branches or pull requests

6 participants