Skip to content

Commit

Permalink
Tap15.0.1 support (#2986)
Browse files Browse the repository at this point in the history
* feat: migrating methods

* feat: migrate body limit

* feat: migrated 404s tests

* feat: migrated 404s tests

* feat: fix the pipeline

* feat: fix tests

* feat: progressing

* feat: fix

* feat: done

* feat: fix changes
  • Loading branch information
veritem committed Apr 8, 2021
1 parent dfd17c4 commit 0ae362b
Show file tree
Hide file tree
Showing 89 changed files with 2,247 additions and 2,246 deletions.
2 changes: 1 addition & 1 deletion .taprc
@@ -1,5 +1,5 @@
esm: false
ts: false
jsx: false
flow: false
check-coverage: false
coverage: true
42 changes: 21 additions & 21 deletions docs/Testing.md
Expand Up @@ -78,7 +78,7 @@ const test = async () => {
test()
```

First, our code will run inside an asynchronous function, giving us access to async/await.
First, our code will run inside an asynchronous function, giving us access to async/await.

`.inject` insures all registered plugins have booted up and our application is ready to test. Finally, we pass the request method we want to use and a route. Using await we can store the response without a callback.

Expand Down Expand Up @@ -116,7 +116,7 @@ test('requests the "/" route', async t => {
method: 'GET',
url: '/'
})
t.strictEqual(response.statusCode, 200, 'returns a status code of 200')
t.equal(response.statusCode, 200, 'returns a status code of 200')
})
```

Expand Down Expand Up @@ -191,7 +191,7 @@ function buildFastify () {
fastify.get('/', function (request, reply) {
reply.send({ hello: 'world' })
})

return fastify
}

Expand All @@ -205,21 +205,21 @@ const buildFastify = require('./app')

tap.test('GET `/` route', t => {
t.plan(4)

const fastify = buildFastify()

// At the end of your tests it is highly recommended to call `.close()`
// to ensure that all connections to external services get closed.
t.tearDown(() => fastify.close())
t.teardown(() => fastify.close())

fastify.inject({
method: 'GET',
url: '/'
}, (err, response) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8')
t.deepEqual(response.json(), { hello: 'world' })
t.equal(response.statusCode, 200)
t.equal(response.headers['content-type'], 'application/json; charset=utf-8')
t.same(response.json(), { hello: 'world' })
})
})
```
Expand All @@ -239,22 +239,22 @@ const buildFastify = require('./app')

tap.test('GET `/` route', t => {
t.plan(5)

const fastify = buildFastify()
t.tearDown(() => fastify.close())

t.teardown(() => fastify.close())

fastify.listen(0, (err) => {
t.error(err)

request({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
t.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8')
t.deepEqual(JSON.parse(body), { hello: 'world' })
t.equal(response.statusCode, 200)
t.equal(response.headers['content-type'], 'application/json; charset=utf-8')
t.same(JSON.parse(body), { hello: 'world' })
})
})
})
Expand All @@ -269,15 +269,15 @@ const buildFastify = require('./app')
tap.test('GET `/` route', async (t) => {
const fastify = buildFastify()

t.tearDown(() => fastify.close())
t.teardown(() => fastify.close())

await fastify.ready()

const response = await supertest(fastify.server)
.get('/')
.expect(200)
.expect('Content-Type', 'application/json; charset=utf-8')
t.deepEqual(response.body, { hello: 'world' })
t.same(response.body, { hello: 'world' })
})
```

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -163,7 +163,7 @@
"snazzy": "^9.0.0",
"split2": "^3.1.1",
"standard": "^16.0.1",
"tap": "^14.4.1",
"tap": "^15.0.1",
"tap-mocha-reporter": "^5.0.0",
"then-sleep": "^1.0.1",
"tsd": "^0.14.0",
Expand Down

0 comments on commit 0ae362b

Please sign in to comment.