How to use the apollo-server-testing.createTestClient function in apollo-server-testing

To help you get started, we’ve selected a few apollo-server-testing examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apollo-model / apollo-model / packages / core / __tests__ / integration-prepare.ts View on Github external
// console.log('result', result);
        return result;
      },
    };
  },
  introspection: true,
  playground: true,
  formatError: error => {
    // console.log(error);
    // console.dir(error.extensions);
    return error;
  },
});

const { createTestClient } = require('apollo-server-testing');
export const { query, mutate } = createTestClient(server);
github Human-Connection / Human-Connection / backend / src / middleware / softDelete / softDeleteMiddleware.spec.js View on Github external
author: troll,
    postId: 'p3',
    content: 'Disabled comment',
    contentExcerpt: 'Disabled comment',
  })

  const { server } = createServer({
    context: () => {
      return {
        driver,
        neode,
        user: authenticatedUser,
      }
    },
  })
  const client = createTestClient(server)
  query = client.query
  mutate = client.mutate

  authenticatedUser = await moderator.toJson()
  const disableMutation = gql`
    mutation($id: ID!) {
      disable(id: $id)
    }
  `
  await Promise.all([
    mutate({ mutation: disableMutation, variables: { id: 'c1' } }),
    mutate({ mutation: disableMutation, variables: { id: 'u2' } }),
    mutate({ mutation: disableMutation, variables: { id: 'p2' } }),
  ])
  authenticatedUser = null
})
github Human-Connection / Human-Connection / backend / src / middleware / validation / validationMiddleware.spec.js View on Github external
beforeAll(() => {
  const { server } = createServer({
    context: () => {
      return {
        user: authenticatedUser,
        neode,
        driver,
      }
    },
  })
  mutate = createTestClient(server).mutate
})
github Human-Connection / Human-Connection / backend / src / middleware / hashtags / hashtagsMiddleware.spec.js View on Github external
beforeAll(() => {
  const createServerResult = createServer({
    context: () => {
      return {
        user: authenticatedUser,
        neode: instance,
        driver,
      }
    },
  })
  server = createServerResult.server
  const createTestClientResult = createTestClient(server)
  query = createTestClientResult.query
  mutate = createTestClientResult.mutate
})
github Human-Connection / Human-Connection / backend / src / schema / resolvers / shout.spec.js View on Github external
beforeAll(() => {
    authenticatedUser = undefined
    const { server } = createServer({
      context: () => {
        return {
          driver,
          neode: instance,
          user: authenticatedUser,
        }
      },
    })
    mutate = createTestClient(server).mutate
    query = createTestClient(server).query
  })
  beforeEach(async () => {
github Human-Connection / Human-Connection / backend / src / schema / resolvers / passwordReset.spec.js View on Github external
beforeAll(() => {
  const { server } = createServer({
    context: () => {
      return {
        driver,
        neode,
        user: authenticatedUser,
      }
    },
  })
  mutate = createTestClient(server).mutate
})
github Human-Connection / Human-Connection / backend / src / schema / resolvers / rewards.spec.js View on Github external
beforeAll(async () => {
    const { server } = createServer({
      context: () => {
        return {
          driver,
          neode: instance,
          user: authenticatedUser,
        }
      },
    })
    query = createTestClient(server).query
    mutate = createTestClient(server).mutate
  })
github Human-Connection / Human-Connection / backend / src / schema / resolvers / posts.spec.js View on Github external
beforeAll(async () => {
  await factory.cleanDatabase()
  const { server } = createServer({
    context: () => {
      return {
        driver,
        neode,
        user: authenticatedUser,
      }
    },
  })
  query = createTestClient(server).query
  mutate = createTestClient(server).mutate
})
github Human-Connection / Human-Connection / backend / src / schema / resolvers / notifications.spec.js View on Github external
beforeAll(() => {
  const { server } = createServer({
    context: () => {
      return {
        driver,
        user: authenticatedUser,
      }
    },
  })
  query = createTestClient(server).query
  mutate = createTestClient(server).mutate
})
github Human-Connection / Human-Connection / backend / src / middleware / notifications / notificationsMiddleware.spec.js View on Github external
data: {
              notifications: [
                {
                  read: false,
                  createdAt: { formatted: expect.any(String) },
                  reason: 'mentioned_in_post',
                  from: {
                    __typename: 'Post',
                    id: 'p47',
                    content: expectedContent,
                  },
                },
              ],
            },
          })
          const { query } = createTestClient(server)
          await expect(
            query({
              query: notificationQuery,
              variables: {
                read: false,
              },
            }),
          ).resolves.toEqual(expected)
        })

apollo-server-testing

Test utils for apollo-server

MIT
Latest version published 3 years ago

Package Health Score

68 / 100
Full package analysis

Popular apollo-server-testing functions