Skip to content

Commit

Permalink
more flexible getSchema function
Browse files Browse the repository at this point in the history
  • Loading branch information
singingwolfboy committed Oct 13, 2019
1 parent e1aff3d commit 727a195
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 3 additions & 4 deletions packages/jest-serializer-graphql-schema/README.md
Expand Up @@ -43,8 +43,7 @@ import {
buildClientSchema,
} from "graphql";

const getPokemonSchema = async () => {
const url = "https://graphql-pokemon.now.sh";
const getSchema = async (url: string) => {
const response = await fetch(url, {
method: "POST",
body: JSON.stringify({ query: getIntrospectionQuery() }),
Expand All @@ -57,9 +56,9 @@ const getPokemonSchema = async () => {
};

test("Pokemon GraphQL API has a consistent schema", async () => {
const schema = await getPokemonSchema();
const schema = await getSchema("https://graphql-pokemon.now.sh");
expect(schema).toMatchSnapshot();
});
});;
```

This test will produce the following snapshot:
Expand Down
Expand Up @@ -8,8 +8,7 @@ import {
const GraphQLSchemaSnapshotSerializer = require("../src");
expect.addSnapshotSerializer(GraphQLSchemaSnapshotSerializer);

const getPokemonSchema = async () => {
const url = "https://graphql-pokemon.now.sh";
const getSchema = async (url: string) => {
const response = await fetch(url, {
method: "POST",
body: JSON.stringify({ query: getIntrospectionQuery() }),
Expand All @@ -22,6 +21,6 @@ const getPokemonSchema = async () => {
};

test("Pokemon GraphQL API has a consistent schema", async () => {
const schema = await getPokemonSchema();
const schema = await getSchema("https://graphql-pokemon.now.sh");
expect(schema).toMatchSnapshot();
});

0 comments on commit 727a195

Please sign in to comment.