Skip to content

Instantly share code, notes, and snippets.

@danahartweg
Last active July 2, 2022 17:55
Show Gist options
  • Save danahartweg/d2141b6cf79168cd8641b2b72ae6343d to your computer and use it in GitHub Desktop.
Save danahartweg/d2141b6cf79168cd8641b2b72ae6343d to your computer and use it in GitHub Desktop.
Client test harness - Unit testing Flutter GraphQL
MockGraphQLClient generateMockGraphQLClient() {
final graphQLClient = MockGraphQLClient();
final queryManager = MockQueryManager();
when(() => graphQLClient.defaultPolicies).thenReturn(DefaultPolicies());
when(() => graphQLClient.queryManager).thenReturn(queryManager);
return graphQLClient;
}
class MockGraphQLClient extends Mock implements GraphQLClient {}
class MockQueryManager extends Mock implements QueryManager {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment