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

Allow setting a "loading time" to MockedProvider #239

Closed
GuillaumeDesforges opened this issue Jul 13, 2020 · 4 comments
Closed

Allow setting a "loading time" to MockedProvider #239

GuillaumeDesforges opened this issue Jul 13, 2020 · 4 comments
Labels
project-apollo-client (legacy) LEGACY TAG DO NOT USE 🧪 testing Feature requests related to testing

Comments

@GuillaumeDesforges
Copy link

When working on my frontend, I want to be able to see the UI I have made for when the GraphQL query/mutation is loading to check it is done properly and the UX is good, or even just to show to my clients the UX in mocked mode.

For now I have to set breakpoints, but it is hardly usable.

An option to "delay" the MockedProvider response by a constant time (responseDelay: 1000) for all queries would help that.

@jpvajda jpvajda added the project-apollo-client (legacy) LEGACY TAG DO NOT USE label Aug 24, 2022
@jpvajda
Copy link
Contributor

jpvajda commented Aug 24, 2022

@jerelmiller jerelmiller added the 🧪 testing Feature requests related to testing label Apr 6, 2023
@jerelmiller
Copy link
Member

Hey @GuillaumeDesforges 👋

Unfortunately its not well documented but mocked responses accept a delay option that allows you to specify the number of milliseconds the mocked response should wait before "sending" that response. You can use it as such:

const mocks = [
  { 
    request: { query },
    result: { data: { ... } },
    delay: 100 // delay for 100ms
  }
]

<MockedProvider mocks={mocks}>
  {children}
</MockedProvider>

Does this address what you're looking for? I'll see if we can get this documented in our testing docs.

@GuillaumeDesforges
Copy link
Author

Looks like it, thanks @jerelmiller 😄

@jerelmiller
Copy link
Member

Great to hear! I'm going to go ahead and close this. Thanks!

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

No branches or pull requests

3 participants