Created
May 1, 2018 23:42
-
-
Save israeleriston/38b4b4c66b23465fbd8ebc63e1a362ca to your computer and use it in GitHub Desktop.
Tests with Ava
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
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