menu

Apollo

A community of developers, designers and others who love Apollo and GraphQL. 🚀

Channels
# All channels
view-forward
# General
view-forward
# Apollo Angular
view-forward
# Announcements
view-forward
# Apollo Android
view-forward
# Apollo Client
view-forward
# Apollo iOS
view-forward
# Apollo Link
view-forward
# Apollo Link Rest
view-forward
# Local State
view-forward
# Apollo Studio
view-forward
# Apollo Server
view-forward
# Apollo Tooling
view-forward
# Contributing
view-forward
# Docs
view-forward
# Events
view-forward
# GraphQL Tools
view-forward
# Jobs
view-forward
# Random
view-forward
# React Apollo
view-forward
# Showcase
view-forward
# Subscriptions
view-forward
# Testing
view-forward
# Vue Apollo
view-forward
Team
Posts
Members
Info

Testing one query with multiple results

Hi there, I'm trying to test all possible values for a custom hook I did, based on the result of a query. To do that, I'm using MockedProvider. The problem is because I can't find an easy way to mock different responses not copy-pasting multiple MockedProvider with different…

thumbsup
0
message-simple
0

How can I test that the shape of the data passed into useMutation?

I am following the official doc here: https://www.apollographql.com/docs/react/development-testing/testing/ to create tests for my react component. However, I can't seem to find a way to test the shape of the data that is passed into the mutation and I am interested in doing so…

thumbsup
0
message-simple
0

Mutation not updating graphql cache when using MockedProvider

In a non-testing environment for my React Apollo apps, when a mutation returns with some new data, the graphql cache will be updated, which then causes component to re-render and display the new data. But I've never been able to replicate that when testing using MockedProvider.…

thumbsup
0
message-simple
0

How to test useLazyQuery?

I love the documentation about testing react components with useQuery and useMutation. (https://www.apollographql.com/docs/react/development-testing/testing/) But I struggle when testing the useLazyQuery-hook. …

thumbsup
2
message-simple
8

MockedProvider mocks are impossible to maintain

I'm really thankful for Apollo and the MockedProvider utility. Both great tools. The issue I'm currently having though is that I'm finding it way too time consuming trying to maintain my mocks. How can I debug the MockedProvider constantly returning nothing? It has been taking…

thumbsup
1
message-simple
0
Deleted·100d# Testing

apollo-datasource-rest + Typescript + Jest

I am setting up a new project using Apollo, TypeScript & Jest and I'm running into some difficulty testing my datasources that extent RESTDataSource. Jest will not mock the class to be extended & much of the advice I'm coming across recommends switching to composition over…

thumbsup
2
message-simple
4

MockedProvider error Could not find "client"

Updated to @apollo/client/testing from @apollo/react-testing. Changed import { MockedProvider } from '@apollo/client/testing'; Still we have an error while running jest tests "Invariant Violation: Could not find "client" in the context or passed in as an option. Wrap the root…

thumbsup
0
message-simple
0

Mutation doesn't resolve in Jest test

Getting the following error: Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout. The console.log('created log') never runs. I've been stuck on this for two days, so any help would be hugely appreciated! The test: …

thumbsup
0
message-simple
0

Fragment is not working with MockedProvider

When I use a fragment in my code, it works in a browser environment, but it fails in the tests when using MockedProvider from Apollo. If my Fragment looks like this: My fragment looks like this: …

thumbsup
1
message-simple
5

fields contained in fragment are not being returned from mocks

Intended outcome: I'm trying to write some tests that involve some queries that contains fragments in them. The fields in the fragments get retrieved just fine in the local environment, but when I try to run it through jest, I get back all the fields except for the ones in the…

thumbsup
1
message-simple
1