1.0.2 • Published 4 years ago

fastify-gql-integration-testing v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

fastify-gql-integration-testing

npm version

yarn add fastify-gql-integration-testing
# or
npm install fastify-gql-integration-testing

Features

  • TypeScript support
  • query | mutation.
  • batchQueries.
  • headers management.
  • cookies management.

Usage

// app.ts | app.js
import Fastify from "fastify";
import GQL from "fastify-gql";
import schema from "./schema";
import { buildContext } from "./buildContext";

export const app = Fastify();

app.register(GQL, {
  schema,
  resolvers: {},
  context: buildContext,
});
// integration.test.js | integration.test.ts

import { createFastifyGQLTestClient } from "fastify-gql-integration-testing";
import { app } from "../app";

// ...

const testClient = createFastifyGQLTestClient(app);

expect(testClient.query("query { helloWorld }")).resolves.toEqual({
  data: {
    helloWorld: "helloWorld",
  },
});