Last active
February 1, 2020 22:57
-
-
Save seandearnaley/92bed116302c90b5ad21879e69fe8e88 to your computer and use it in GitHub Desktop.
BrainStrike Server End-2-End Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
GraphQLRequest, | |
Observable, | |
FetchResult, | |
toPromise | |
} from "apollo-link"; | |
import { | |
startTestServer, | |
constructTestServer, | |
createTestingConnection, | |
Connection | |
} from "./__utils"; | |
import gql from "graphql-tag"; | |
const GET_CARDS = gql` | |
query getCards { | |
cards { | |
id | |
number | |
label | |
description | |
} | |
} | |
`; | |
describe("Server - e2e", () => { | |
let connection: Connection; | |
let stop: () => void, | |
graphql: ({}: GraphQLRequest) => Observable<FetchResult>; | |
beforeAll(async () => { | |
connection = await createTestingConnection(); | |
}); | |
beforeEach(async () => { | |
const { apolloServer } = await constructTestServer(connection); | |
const testServer = await startTestServer(apolloServer); | |
stop = testServer.stop; | |
graphql = testServer.graphql; | |
}); | |
afterEach(async () => { | |
stop(); | |
}); | |
afterAll(async () => { | |
await connection.close(); | |
}); | |
it("gets list of cards", async () => { | |
const res = await toPromise( | |
graphql({ | |
query: GET_CARDS | |
}) | |
); | |
expect(res).toMatchSnapshot(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment