Created
June 7, 2019 08:19
-
-
Save philsch/4dd6551f1d1348abd76bbe81601ea07a to your computer and use it in GitHub Desktop.
Blogpost: Easy integration testing of GraphQL with Jest
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 * as util from 'util'; | |
import * as rp from 'request-promise'; | |
import { exec } from 'child_process'; | |
const pExec = util.promisify(exec); | |
const API = 'http://localhost:4466/'; | |
const CMD_SEED_DATABASE = `${__dirname}/../seed.sh`; | |
describe('Getting shop items', () => { | |
beforeAll(async () => { | |
await pExec(CMD_SEED_DATABASE); | |
}); | |
it('Retrieves the shop items in default order', async () => { | |
const query = ` | |
query { | |
shopItems { | |
name | |
category | |
size | |
} | |
} | |
`; | |
const response = await rp({method: 'POST', uri: API, body: {query}, json: true}); | |
expect(response).toMatchSnapshot(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment