fastify 5.2.0 → 5.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/LICENSE +1 -1
  2. package/PROJECT_CHARTER.md +7 -7
  3. package/README.md +65 -67
  4. package/SPONSORS.md +2 -0
  5. package/build/build-validation.js +1 -1
  6. package/docs/Guides/Benchmarking.md +4 -4
  7. package/docs/Guides/Database.md +1 -1
  8. package/docs/Guides/Delay-Accepting-Requests.md +10 -10
  9. package/docs/Guides/Ecosystem.md +5 -1
  10. package/docs/Guides/Fluent-Schema.md +1 -1
  11. package/docs/Guides/Getting-Started.md +9 -5
  12. package/docs/Guides/Index.md +1 -1
  13. package/docs/Guides/Migration-Guide-V4.md +1 -1
  14. package/docs/Guides/Migration-Guide-V5.md +12 -2
  15. package/docs/Guides/Plugins-Guide.md +6 -6
  16. package/docs/Guides/Serverless.md +14 -48
  17. package/docs/Guides/Style-Guide.md +2 -2
  18. package/docs/Guides/Testing.md +2 -2
  19. package/docs/Guides/Write-Plugin.md +2 -3
  20. package/docs/Reference/ContentTypeParser.md +58 -78
  21. package/docs/Reference/Decorators.md +50 -60
  22. package/docs/Reference/Encapsulation.md +28 -33
  23. package/docs/Reference/Errors.md +52 -53
  24. package/docs/Reference/HTTP2.md +7 -7
  25. package/docs/Reference/Hooks.md +31 -30
  26. package/docs/Reference/LTS.md +10 -15
  27. package/docs/Reference/Lifecycle.md +19 -24
  28. package/docs/Reference/Logging.md +59 -56
  29. package/docs/Reference/Middleware.md +19 -19
  30. package/docs/Reference/Plugins.md +55 -71
  31. package/docs/Reference/Principles.md +25 -30
  32. package/docs/Reference/Reply.md +11 -10
  33. package/docs/Reference/Request.md +89 -99
  34. package/docs/Reference/Routes.md +108 -128
  35. package/docs/Reference/Server.md +19 -17
  36. package/docs/Reference/Type-Providers.md +19 -21
  37. package/docs/Reference/TypeScript.md +1 -18
  38. package/docs/Reference/Validation-and-Serialization.md +134 -159
  39. package/docs/Reference/Warnings.md +22 -25
  40. package/fastify.js +1 -1
  41. package/lib/contentTypeParser.js +7 -8
  42. package/lib/error-handler.js +14 -12
  43. package/lib/errors.js +4 -0
  44. package/lib/headRoute.js +4 -2
  45. package/lib/pluginUtils.js +4 -2
  46. package/lib/reply.js +4 -0
  47. package/lib/request.js +13 -9
  48. package/lib/server.js +5 -0
  49. package/lib/validation.js +1 -1
  50. package/lib/warnings.js +9 -0
  51. package/lib/wrapThenable.js +8 -1
  52. package/package.json +28 -17
  53. package/test/build/error-serializer.test.js +2 -1
  54. package/test/bundler/esbuild/package.json +1 -1
  55. package/test/close.test.js +125 -108
  56. package/test/custom-parser-async.test.js +34 -36
  57. package/test/custom-parser.2.test.js +19 -20
  58. package/test/custom-parser.3.test.js +56 -45
  59. package/test/delete.test.js +79 -67
  60. package/test/genReqId.test.js +125 -174
  61. package/test/has-route.test.js +1 -3
  62. package/test/internals/content-type-parser.test.js +1 -1
  63. package/test/internals/errors.test.js +19 -7
  64. package/test/issue-4959.test.js +84 -0
  65. package/test/listen.1.test.js +37 -34
  66. package/test/listen.2.test.js +47 -40
  67. package/test/listen.3.test.js +28 -32
  68. package/test/listen.4.test.js +61 -45
  69. package/test/listen.5.test.js +23 -0
  70. package/test/nullable-validation.test.js +30 -27
  71. package/test/register.test.js +55 -50
  72. package/test/request-error.test.js +114 -94
  73. package/test/route-shorthand.test.js +36 -32
  74. package/test/server.test.js +0 -175
  75. package/test/stream.5.test.js +35 -33
  76. package/test/throw.test.js +87 -91
  77. package/test/toolkit.js +32 -0
  78. package/test/trust-proxy.test.js +23 -23
  79. package/test/types/instance.test-d.ts +1 -0
  80. package/test/upgrade.test.js +32 -30
  81. package/test/web-api.test.js +44 -0
  82. package/types/instance.d.ts +4 -0
  83. package/test/test-reporter.mjs +0 -68
@@ -1,11 +1,12 @@
1
1
  'use strict'
2
2
 
3
- const { test, before } = require('tap')
3
+ const { test, before } = require('node:test')
4
4
  const dns = require('node:dns').promises
5
5
  const dnsCb = require('node:dns')
6
6
  const sget = require('simple-get').concat
7
7
  const Fastify = require('../fastify')
8
8
  const helper = require('./helper')
9
+ const { waitForCb } = require('./toolkit')
9
10
 
10
11
  let localhostForURL
11
12
 
@@ -22,64 +23,69 @@ before(async function () {
22
23
  [, localhostForURL] = await helper.getLoopbackHost()
23
24
  })
24
25
 
25
- test('listen twice on the same port without callback rejects', t => {
26
+ test('listen twice on the same port without callback rejects', (t, done) => {
26
27
  t.plan(1)
27
28
  const fastify = Fastify()
28
- t.teardown(fastify.close.bind(fastify))
29
+ t.after(() => fastify.close())
29
30
 
30
31
  fastify.listen({ port: 0 })
31
32
  .then(() => {
32
- const s2 = Fastify()
33
- t.teardown(s2.close.bind(s2))
34
- s2.listen({ port: fastify.server.address().port })
33
+ const server2 = Fastify()
34
+ t.after(() => server2.close())
35
+ server2.listen({ port: fastify.server.address().port })
35
36
  .catch(err => {
36
- t.ok(err)
37
+ t.assert.ok(err)
38
+ done()
37
39
  })
38
40
  })
39
- .catch(err => t.error(err))
41
+ .catch(err => {
42
+ t.assert.ifError(err)
43
+ })
40
44
  })
41
45
 
42
- test('listen twice on the same port without callback rejects with (address)', t => {
46
+ test('listen twice on the same port without callback rejects with (address)', (t, done) => {
43
47
  t.plan(2)
44
48
  const fastify = Fastify()
45
- t.teardown(fastify.close.bind(fastify))
49
+ t.after(() => fastify.close())
46
50
  fastify.listen({ port: 0 })
47
51
  .then(address => {
48
- const s2 = Fastify()
49
- t.teardown(s2.close.bind(s2))
50
- t.equal(address, `http://${localhostForURL}:${fastify.server.address().port}`)
51
- s2.listen({ port: fastify.server.address().port })
52
+ const server2 = Fastify()
53
+ t.after(() => server2.close())
54
+ t.assert.strictEqual(address, `http://${localhostForURL}:${fastify.server.address().port}`)
55
+
56
+ server2.listen({ port: fastify.server.address().port })
52
57
  .catch(err => {
53
- t.ok(err)
58
+ t.assert.ok(err)
59
+ done()
54
60
  })
55
61
  })
56
- .catch(err => t.error(err))
62
+ .catch(err => {
63
+ t.assert.ifError(err)
64
+ })
57
65
  })
58
66
 
59
67
  test('listen on invalid port without callback rejects', t => {
60
68
  const fastify = Fastify()
61
- t.teardown(fastify.close.bind(fastify))
69
+ t.after(() => fastify.close())
62
70
  return fastify.listen({ port: -1 })
63
71
  .catch(err => {
64
- t.ok(err)
72
+ t.assert.ok(err)
65
73
  return true
66
74
  })
67
75
  })
68
76
 
69
- test('listen logs the port as info', t => {
77
+ test('listen logs the port as info', async t => {
70
78
  t.plan(1)
71
79
  const fastify = Fastify()
72
- t.teardown(fastify.close.bind(fastify))
80
+ t.after(() => fastify.close())
73
81
 
74
82
  const msgs = []
75
83
  fastify.log.info = function (msg) {
76
84
  msgs.push(msg)
77
85
  }
78
86
 
79
- fastify.listen({ port: 0 })
80
- .then(() => {
81
- t.ok(/http:\/\//.test(msgs[0]))
82
- })
87
+ await fastify.listen({ port: 0 })
88
+ t.assert.ok(/http:\/\//.test(msgs[0]))
83
89
  })
84
90
 
85
91
  test('listen on localhost binds IPv4 and IPv6 - promise interface', async t => {
@@ -88,7 +94,7 @@ test('listen on localhost binds IPv4 and IPv6 - promise interface', async t => {
88
94
 
89
95
  const app = Fastify()
90
96
  app.get('/', async () => 'hello localhost')
91
- t.teardown(app.close.bind(app))
97
+ t.after(() => app.close())
92
98
  await app.listen({ port: 0, host: 'localhost' })
93
99
 
94
100
  for (const lookup of localAddresses) {
@@ -98,34 +104,43 @@ test('listen on localhost binds IPv4 and IPv6 - promise interface', async t => {
98
104
  url: getUrl(app, lookup)
99
105
  }, (err, response, body) => {
100
106
  if (err) { return reject(err) }
101
- t.equal(response.statusCode, 200)
102
- t.same(body.toString(), 'hello localhost')
107
+ t.assert.strictEqual(response.statusCode, 200)
108
+ t.assert.deepStrictEqual(body.toString(), 'hello localhost')
103
109
  resolve()
104
110
  })
105
111
  })
106
112
  }
107
113
  })
108
114
 
109
- test('listen on localhost binds to all interfaces (both IPv4 and IPv6 if present) - callback interface', t => {
115
+ test('listen on localhost binds to all interfaces (both IPv4 and IPv6 if present) - callback interface', (t, done) => {
110
116
  dnsCb.lookup('localhost', { all: true }, (err, lookups) => {
111
117
  t.plan(2 + (3 * lookups.length))
112
- t.error(err)
118
+ t.assert.ifError(err)
113
119
 
114
120
  const app = Fastify()
115
121
  app.get('/', async () => 'hello localhost')
116
122
  app.listen({ port: 0, host: 'localhost' }, (err) => {
117
- t.error(err)
118
- t.teardown(app.close.bind(app))
119
-
120
- for (const lookup of lookups) {
121
- sget({
122
- method: 'GET',
123
- url: getUrl(app, lookup)
124
- }, (err, response, body) => {
125
- t.error(err)
126
- t.equal(response.statusCode, 200)
127
- t.same(body.toString(), 'hello localhost')
128
- })
123
+ t.assert.ifError(err)
124
+ t.after(() => app.close())
125
+
126
+ const { stepIn, patience } = waitForCb({ steps: lookups.length })
127
+
128
+ // Loop over each lookup and perform the assertions
129
+ if (lookups.length > 0) {
130
+ for (const lookup of lookups) {
131
+ sget({
132
+ method: 'GET',
133
+ url: getUrl(app, lookup)
134
+ }, (err, response, body) => {
135
+ t.assert.ifError(err)
136
+ t.assert.strictEqual(response.statusCode, 200)
137
+ t.assert.deepStrictEqual(body.toString(), 'hello localhost')
138
+ // Call stepIn to report that a request has been completed
139
+ stepIn()
140
+ })
141
+ }
142
+ // When all requests have been completed, call done
143
+ patience.then(() => done())
129
144
  }
130
145
  })
131
146
  })
@@ -137,11 +152,12 @@ test('addresses getter', async t => {
137
152
  t.plan(4)
138
153
  const app = Fastify()
139
154
  app.get('/', async () => 'hello localhost')
155
+ t.after(() => app.close())
140
156
 
141
- t.same(app.addresses(), [], 'before ready')
157
+ t.assert.deepStrictEqual(app.addresses(), [], 'before ready')
142
158
  await app.ready()
143
159
 
144
- t.same(app.addresses(), [], 'after ready')
160
+ t.assert.deepStrictEqual(app.addresses(), [], 'after ready')
145
161
  await app.listen({ port: 0, host: 'localhost' })
146
162
 
147
163
  // fix citgm
@@ -157,8 +173,8 @@ test('addresses getter', async t => {
157
173
  family: typeof a.family === 'number' ? 'IPv' + a.family : a.family
158
174
  })).sort()
159
175
 
160
- t.same(appAddresses, localAddresses, 'after listen')
176
+ t.assert.deepStrictEqual(appAddresses, localAddresses, 'after listen')
161
177
 
162
178
  await app.close()
163
- t.same(app.addresses(), [], 'after close')
179
+ t.assert.deepStrictEqual(app.addresses(), [], 'after close')
164
180
  })
@@ -4,6 +4,7 @@ const { test } = require('node:test')
4
4
  const net = require('node:net')
5
5
  const Fastify = require('../fastify')
6
6
  const { once } = require('node:events')
7
+ const { FSTWRN003 } = require('../lib/warnings.js')
7
8
 
8
9
  function createDeferredPromise () {
9
10
  const promise = {}
@@ -97,3 +98,25 @@ test('same port conflict and success should not fire callback multiple times - p
97
98
  await fastify.listen()
98
99
  await fastify.close()
99
100
  })
101
+
102
+ test('should emit a warning when using async callback', (t, done) => {
103
+ t.plan(2)
104
+
105
+ process.on('warning', onWarning)
106
+ function onWarning (warning) {
107
+ t.assert.strictEqual(warning.name, 'FastifyWarning')
108
+ t.assert.strictEqual(warning.code, FSTWRN003.code)
109
+ }
110
+
111
+ const fastify = Fastify()
112
+
113
+ t.after(async () => {
114
+ await fastify.close()
115
+ process.removeListener('warning', onWarning)
116
+ FSTWRN003.emitted = false
117
+ })
118
+
119
+ fastify.listen({ port: 0 }, async function doNotUseAsyncCallback () {
120
+ done()
121
+ })
122
+ })
@@ -1,18 +1,17 @@
1
1
  'use strict'
2
2
 
3
- const t = require('tap')
4
- const test = t.test
3
+ const { test } = require('node:test')
5
4
  const sget = require('simple-get').concat
6
5
  const Fastify = require('..')
7
6
 
8
- test('nullable string', t => {
7
+ test('nullable string', (t, done) => {
9
8
  t.plan(3)
10
9
  const fastify = Fastify()
11
10
  fastify.route({
12
11
  method: 'POST',
13
12
  url: '/',
14
13
  handler: (req, reply) => {
15
- t.same(req.body.hello, null)
14
+ t.assert.strictEqual(req.body.hello, null)
16
15
  reply.code(200).send(req.body)
17
16
  },
18
17
  schema: {
@@ -47,12 +46,13 @@ test('nullable string', t => {
47
46
  hello: null
48
47
  }
49
48
  }, (err, res) => {
50
- t.error(err)
51
- t.same(res.payload.hello, null)
49
+ t.assert.ifError(err)
50
+ t.assert.strictEqual(res.json().hello, null)
51
+ done()
52
52
  })
53
53
  })
54
54
 
55
- test('object or null body', t => {
55
+ test('object or null body', (t, done) => {
56
56
  t.plan(5)
57
57
 
58
58
  const fastify = Fastify()
@@ -61,7 +61,7 @@ test('object or null body', t => {
61
61
  method: 'POST',
62
62
  url: '/',
63
63
  handler: (req, reply) => {
64
- t.equal(req.body, undefined)
64
+ t.assert.strictEqual(req.body, undefined)
65
65
  reply.code(200).send({ isUndefinedBody: req.body === undefined })
66
66
  },
67
67
  schema: {
@@ -89,21 +89,22 @@ test('object or null body', t => {
89
89
  })
90
90
 
91
91
  fastify.listen({ port: 0 }, (err) => {
92
- t.error(err)
93
- t.teardown(() => { fastify.close() })
92
+ t.assert.ifError(err)
93
+ t.after(() => { fastify.close() })
94
94
 
95
95
  sget({
96
96
  method: 'POST',
97
97
  url: 'http://localhost:' + fastify.server.address().port
98
98
  }, (err, response, body) => {
99
- t.error(err)
100
- t.equal(response.statusCode, 200)
101
- t.same(JSON.parse(body), { isUndefinedBody: true })
99
+ t.assert.ifError(err)
100
+ t.assert.strictEqual(response.statusCode, 200)
101
+ t.assert.deepStrictEqual(JSON.parse(body), { isUndefinedBody: true })
102
+ done()
102
103
  })
103
104
  })
104
105
  })
105
106
 
106
- test('nullable body', t => {
107
+ test('nullable body', (t, done) => {
107
108
  t.plan(5)
108
109
 
109
110
  const fastify = Fastify()
@@ -112,7 +113,7 @@ test('nullable body', t => {
112
113
  method: 'POST',
113
114
  url: '/',
114
115
  handler: (req, reply) => {
115
- t.equal(req.body, undefined)
116
+ t.assert.strictEqual(req.body, undefined)
116
117
  reply.code(200).send({ isUndefinedBody: req.body === undefined })
117
118
  },
118
119
  schema: {
@@ -141,21 +142,22 @@ test('nullable body', t => {
141
142
  })
142
143
 
143
144
  fastify.listen({ port: 0 }, (err) => {
144
- t.error(err)
145
- t.teardown(() => { fastify.close() })
145
+ t.assert.ifError(err)
146
+ t.after(() => fastify.close())
146
147
 
147
148
  sget({
148
149
  method: 'POST',
149
150
  url: 'http://localhost:' + fastify.server.address().port
150
151
  }, (err, response, body) => {
151
- t.error(err)
152
- t.equal(response.statusCode, 200)
153
- t.same(JSON.parse(body), { isUndefinedBody: true })
152
+ t.assert.ifError(err)
153
+ t.assert.strictEqual(response.statusCode, 200)
154
+ t.assert.deepStrictEqual(JSON.parse(body), { isUndefinedBody: true })
155
+ done()
154
156
  })
155
157
  })
156
158
  })
157
159
 
158
- test('Nullable body with 204', t => {
160
+ test('Nullable body with 204', (t, done) => {
159
161
  t.plan(5)
160
162
 
161
163
  const fastify = Fastify()
@@ -164,7 +166,7 @@ test('Nullable body with 204', t => {
164
166
  method: 'POST',
165
167
  url: '/',
166
168
  handler: (req, reply) => {
167
- t.equal(req.body, undefined)
169
+ t.assert.strictEqual(req.body, undefined)
168
170
  reply.code(204).send()
169
171
  },
170
172
  schema: {
@@ -182,16 +184,17 @@ test('Nullable body with 204', t => {
182
184
  })
183
185
 
184
186
  fastify.listen({ port: 0 }, (err) => {
185
- t.error(err)
186
- t.teardown(() => { fastify.close() })
187
+ t.assert.ifError(err)
188
+ t.after(() => fastify.close())
187
189
 
188
190
  sget({
189
191
  method: 'POST',
190
192
  url: 'http://localhost:' + fastify.server.address().port
191
193
  }, (err, response, body) => {
192
- t.error(err)
193
- t.equal(response.statusCode, 204)
194
- t.equal(body.length, 0)
194
+ t.assert.ifError(err)
195
+ t.assert.strictEqual(response.statusCode, 204)
196
+ t.assert.strictEqual(body.length, 0)
197
+ done()
195
198
  })
196
199
  })
197
200
  })
@@ -1,21 +1,20 @@
1
1
  'use strict'
2
2
 
3
- const t = require('tap')
4
- const test = t.test
3
+ const { test } = require('node:test')
5
4
  const sget = require('simple-get').concat
6
5
  const Fastify = require('..')
7
6
 
8
- test('register', t => {
9
- t.plan(17)
7
+ test('register', async (t) => {
8
+ t.plan(14)
10
9
 
11
10
  const fastify = Fastify()
12
11
 
13
12
  fastify.register(function (instance, opts, done) {
14
- t.not(instance, fastify)
15
- t.ok(Object.prototype.isPrototypeOf.call(fastify, instance))
13
+ t.assert.notStrictEqual(instance, fastify)
14
+ t.assert.ok(Object.prototype.isPrototypeOf.call(fastify, instance))
16
15
 
17
- t.equal(typeof opts, 'object')
18
- t.equal(typeof done, 'function')
16
+ t.assert.strictEqual(typeof opts, 'object')
17
+ t.assert.strictEqual(typeof done, 'function')
19
18
 
20
19
  instance.get('/first', function (req, reply) {
21
20
  reply.send({ hello: 'world' })
@@ -24,11 +23,11 @@ test('register', t => {
24
23
  })
25
24
 
26
25
  fastify.register(function (instance, opts, done) {
27
- t.not(instance, fastify)
28
- t.ok(Object.prototype.isPrototypeOf.call(fastify, instance))
26
+ t.assert.notStrictEqual(instance, fastify)
27
+ t.assert.ok(Object.prototype.isPrototypeOf.call(fastify, instance))
29
28
 
30
- t.equal(typeof opts, 'object')
31
- t.equal(typeof done, 'function')
29
+ t.assert.strictEqual(typeof opts, 'object')
30
+ t.assert.strictEqual(typeof done, 'function')
32
31
 
33
32
  instance.get('/second', function (req, reply) {
34
33
  reply.send({ hello: 'world' })
@@ -36,28 +35,32 @@ test('register', t => {
36
35
  done()
37
36
  })
38
37
 
39
- fastify.listen({ port: 0 }, err => {
40
- t.error(err)
41
- t.teardown(() => { fastify.close() })
42
-
43
- makeRequest('first')
44
- makeRequest('second')
45
- })
46
-
47
- function makeRequest (path) {
48
- sget({
49
- method: 'GET',
50
- url: 'http://localhost:' + fastify.server.address().port + '/' + path
51
- }, (err, response, body) => {
52
- t.error(err)
53
- t.equal(response.statusCode, 200)
54
- t.equal(response.headers['content-length'], '' + body.length)
55
- t.same(JSON.parse(body), { hello: 'world' })
38
+ await fastify.listen({ port: 0 })
39
+ t.after(() => fastify.close())
40
+
41
+ await makeRequest('first')
42
+ await makeRequest('second')
43
+
44
+ async function makeRequest (path) {
45
+ return new Promise((resolve, reject) => {
46
+ sget({
47
+ method: 'GET',
48
+ url: 'http://localhost:' + fastify.server.address().port + '/' + path
49
+ }, (err, response, body) => {
50
+ if (err) {
51
+ t.assert.ifError(err)
52
+ return reject(err)
53
+ }
54
+ t.assert.strictEqual(response.statusCode, 200)
55
+ t.assert.strictEqual(response.headers['content-length'], '' + body.length)
56
+ t.assert.deepStrictEqual(JSON.parse(body), { hello: 'world' })
57
+ resolve()
58
+ })
56
59
  })
57
60
  }
58
61
  })
59
62
 
60
- test('internal route declaration should pass the error generated by the register to the done handler / 1', t => {
63
+ test('internal route declaration should pass the error generated by the register to the done handler / 1', (t, done) => {
61
64
  t.plan(1)
62
65
  const fastify = Fastify()
63
66
 
@@ -70,12 +73,13 @@ test('internal route declaration should pass the error generated by the register
70
73
  })
71
74
 
72
75
  fastify.listen({ port: 0 }, err => {
73
- fastify.close()
74
- t.equal(err.message, 'kaboom')
76
+ t.after(() => fastify.close())
77
+ t.assert.strictEqual(err.message, 'kaboom')
78
+ done()
75
79
  })
76
80
  })
77
81
 
78
- test('internal route declaration should pass the error generated by the register to the done handler / 2', t => {
82
+ test('internal route declaration should pass the error generated by the register to the done handler / 2', (t, done) => {
79
83
  t.plan(2)
80
84
  const fastify = Fastify()
81
85
 
@@ -88,12 +92,13 @@ test('internal route declaration should pass the error generated by the register
88
92
  })
89
93
 
90
94
  fastify.after(err => {
91
- t.equal(err.message, 'kaboom')
95
+ t.assert.strictEqual(err.message, 'kaboom')
92
96
  })
93
97
 
94
98
  fastify.listen({ port: 0 }, err => {
95
- fastify.close()
96
- t.error(err)
99
+ t.after(() => fastify.close())
100
+ t.assert.ifError(err)
101
+ done()
97
102
  })
98
103
  })
99
104
 
@@ -107,25 +112,25 @@ test('awaitable register and after', async t => {
107
112
  first = true
108
113
  })
109
114
 
110
- t.equal(first, true)
115
+ t.assert.strictEqual(first, true)
111
116
 
112
117
  fastify.register(async (instance, opts) => {
113
118
  second = true
114
119
  })
115
120
 
116
121
  await fastify.after()
117
- t.equal(second, true)
122
+ t.assert.strictEqual(second, true)
118
123
 
119
124
  fastify.register(async (instance, opts) => {
120
125
  third = true
121
126
  })
122
127
 
123
128
  await fastify.ready()
124
- t.equal(third, true)
129
+ t.assert.strictEqual(third, true)
125
130
  })
126
131
 
127
132
  function thenableRejects (t, promise, error) {
128
- return t.rejects(async () => { await promise }, error)
133
+ return t.assert.rejects(async () => { await promise }, error)
129
134
  }
130
135
 
131
136
  test('awaitable register error handling', async t => {
@@ -138,13 +143,13 @@ test('awaitable register error handling', async t => {
138
143
  }), e)
139
144
 
140
145
  fastify.register(async (instance, opts) => {
141
- t.fail('should not be executed')
146
+ t.assert.fail('should not be executed')
142
147
  })
143
148
 
144
- await t.rejects(fastify.after(), e)
149
+ await t.assert.rejects(fastify.after(), e)
145
150
 
146
151
  fastify.register(async (instance, opts) => {
147
- t.fail('should not be executed')
152
+ t.assert.fail('should not be executed')
148
153
  })
149
154
 
150
155
  await thenableRejects(t, fastify.ready(), e)
@@ -160,16 +165,16 @@ test('awaitable after error handling', async t => {
160
165
  })
161
166
 
162
167
  fastify.register(async (instance, opts) => {
163
- t.fail('should not be executed')
168
+ t.assert.fail('should not be executed')
164
169
  })
165
170
 
166
- await t.rejects(fastify.after(), e)
171
+ await t.assert.rejects(fastify.after(), e)
167
172
 
168
173
  fastify.register(async (instance, opts) => {
169
- t.fail('should not be executed')
174
+ t.assert.fail('should not be executed')
170
175
  })
171
176
 
172
- await t.rejects(fastify.ready())
177
+ await t.assert.rejects(fastify.ready())
173
178
  })
174
179
 
175
180
  test('chainable register', async t => {
@@ -178,11 +183,11 @@ test('chainable register', async t => {
178
183
  const fastify = Fastify()
179
184
 
180
185
  fastify.register(async () => {
181
- t.pass('first loaded')
186
+ t.assert.ok('first loaded')
182
187
  }).register(async () => {
183
- t.pass('second loaded')
188
+ t.assert.ok('second loaded')
184
189
  }).register(async () => {
185
- t.pass('third loaded')
190
+ t.assert.ok('third loaded')
186
191
  })
187
192
 
188
193
  await fastify.ready()