Skip to content

Instantly share code, notes, and snippets.

@israeleriston
Created May 1, 2018 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save israeleriston/38b4b4c66b23465fbd8ebc63e1a362ca to your computer and use it in GitHub Desktop.
Save israeleriston/38b4b4c66b23465fbd8ebc63e1a362ca to your computer and use it in GitHub Desktop.
Tests with Ava
test('Inject GET request fastify', t => {
const fastify = Fastify()
const payload = {
hello: 'world'
}
fastify.get('/', (req, reply) => {
reply.send(payload)
})
fastify.inject({
method: 'GET',
url: '/'
}, (err, res) => {
t.throws(err)
t.deepEqual(payload, JSON.parse(res.payload))
t.deepEqual(res.statusCode, 200)
t.deepEqual(res.headers['content-length'], '17')
t.pass('passing by all tests')
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment