Apollo (v2)
Introduction
Installation
$> yarn add -D enzyme-context enzyme-context-apolloimport fs from 'fs'; import path from 'path'; import { createMount, createShallow } from 'enzyme-context'; import { apolloContext } from 'enzyme-context-apollo'; // path to a .graphql/.gql schema definition for your backend const typeDefs = fs.readFileSync(path.resolve(__dirname), './schema.graphql'); const plugins = { client: apolloContext({ schema: { typeDefs, }, defaultMocks: { Query: () => ({ viewer: () => ({ id: '1612', name: 'Joe Dart', instrument: 'Custom Music Man Bass', }), }), }, }), }; export const mount = createMount(plugins); export const shallow = createShallow(plugins);
Usage
Configuration API
apolloContext(options) => EnzymePlugin
apolloContext(options) => EnzymePluginArguments
Returns
Example:
Mount/Shallow API
FAQ / Tips
Last updated
Was this helpful?