fastify 5.0.0 → 5.2.0

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 (201) hide show
  1. package/.borp.yaml +3 -0
  2. package/.vscode/settings.json +22 -0
  3. package/README.md +12 -7
  4. package/docs/Guides/Database.md +15 -15
  5. package/docs/Guides/Detecting-When-Clients-Abort.md +28 -28
  6. package/docs/Guides/Ecosystem.md +14 -15
  7. package/docs/Guides/Index.md +1 -1
  8. package/docs/Guides/Migration-Guide-V4.md +11 -11
  9. package/docs/Guides/Migration-Guide-V5.md +133 -9
  10. package/docs/Guides/Plugins-Guide.md +1 -1
  11. package/docs/Guides/Prototype-Poisoning.md +3 -3
  12. package/docs/Guides/Recommendations.md +9 -9
  13. package/docs/Guides/Serverless.md +5 -5
  14. package/docs/Guides/Testing.md +58 -57
  15. package/docs/Guides/Write-Plugin.md +2 -2
  16. package/docs/Guides/Write-Type-Provider.md +3 -3
  17. package/docs/Reference/ContentTypeParser.md +4 -4
  18. package/docs/Reference/Decorators.md +2 -2
  19. package/docs/Reference/Errors.md +3 -3
  20. package/docs/Reference/Hooks.md +7 -7
  21. package/docs/Reference/LTS.md +8 -0
  22. package/docs/Reference/Logging.md +5 -4
  23. package/docs/Reference/Reply.md +55 -58
  24. package/docs/Reference/Request.md +49 -42
  25. package/docs/Reference/Routes.md +16 -13
  26. package/docs/Reference/Server.md +32 -28
  27. package/docs/Reference/TypeScript.md +9 -9
  28. package/docs/Reference/Validation-and-Serialization.md +5 -5
  29. package/examples/typescript-server.ts +1 -1
  30. package/fastify.d.ts +14 -5
  31. package/fastify.js +8 -6
  32. package/lib/contentTypeParser.js +9 -7
  33. package/lib/context.js +1 -2
  34. package/lib/error-handler.js +9 -9
  35. package/lib/errors.js +1 -1
  36. package/lib/fourOhFour.js +1 -1
  37. package/lib/hooks.js +4 -1
  38. package/lib/{logger.js → logger-factory.js} +70 -122
  39. package/lib/logger-pino.js +68 -0
  40. package/lib/pluginOverride.js +1 -1
  41. package/lib/pluginUtils.js +2 -2
  42. package/lib/reply.js +4 -5
  43. package/lib/request.js +16 -9
  44. package/lib/route.js +23 -22
  45. package/lib/validation.js +2 -2
  46. package/package.json +13 -15
  47. package/test/404s.test.js +675 -629
  48. package/test/500s.test.js +72 -63
  49. package/test/{allowUnsafeRegex.test.js → allow-unsafe-regex.test.js} +30 -26
  50. package/test/als.test.js +48 -45
  51. package/test/async-await.test.js +148 -134
  52. package/test/async-dispose.test.js +4 -5
  53. package/test/async_hooks.test.js +30 -28
  54. package/test/{bodyLimit.test.js → body-limit.test.js} +61 -58
  55. package/test/buffer.test.js +9 -10
  56. package/test/build/error-serializer.test.js +3 -4
  57. package/test/build/version.test.js +2 -3
  58. package/test/build-certificate.js +1 -1
  59. package/test/bundler/README.md +5 -5
  60. package/test/bundler/esbuild/bundler-test.js +10 -9
  61. package/test/bundler/webpack/bundler-test.js +10 -9
  62. package/test/case-insensitive.test.js +31 -28
  63. package/test/chainable.test.js +4 -5
  64. package/test/check.test.js +8 -10
  65. package/test/{childLoggerFactory.test.js → child-logger-factory.test.js} +56 -19
  66. package/test/client-timeout.test.js +5 -5
  67. package/test/close-pipelining.test.js +6 -8
  68. package/test/conditional-pino.test.js +47 -0
  69. package/test/{connectionTimeout.test.js → connection-timeout.test.js} +10 -11
  70. package/test/constrained-routes.test.js +243 -236
  71. package/test/content-length.test.js +53 -68
  72. package/test/content-parser.test.js +186 -158
  73. package/test/content-type.test.js +8 -9
  74. package/test/context-config.test.js +44 -54
  75. package/test/custom-http-server.test.js +16 -20
  76. package/test/custom-parser.5.test.js +32 -32
  77. package/test/diagnostics-channel/404.test.js +15 -15
  78. package/test/diagnostics-channel/async-delay-request.test.js +25 -25
  79. package/test/diagnostics-channel/async-request.test.js +24 -24
  80. package/test/diagnostics-channel/error-before-handler.test.js +4 -5
  81. package/test/diagnostics-channel/error-request.test.js +19 -19
  82. package/test/diagnostics-channel/error-status.test.js +8 -8
  83. package/test/diagnostics-channel/init.test.js +6 -7
  84. package/test/diagnostics-channel/sync-delay-request.test.js +16 -16
  85. package/test/diagnostics-channel/sync-request-reply.test.js +16 -16
  86. package/test/diagnostics-channel/sync-request.test.js +19 -19
  87. package/test/encapsulated-child-logger-factory.test.js +8 -8
  88. package/test/encapsulated-error-handler.test.js +20 -20
  89. package/test/esm/errorCodes.test.mjs +5 -5
  90. package/test/esm/esm.test.mjs +3 -3
  91. package/test/esm/named-exports.mjs +3 -3
  92. package/test/esm/other.mjs +2 -2
  93. package/test/fastify-instance.test.js +33 -34
  94. package/test/{findRoute.test.js → find-route.test.js} +11 -10
  95. package/test/fluent-schema.test.js +33 -36
  96. package/test/handler-context.test.js +11 -11
  97. package/test/has-route.test.js +12 -15
  98. package/test/header-overflow.test.js +13 -12
  99. package/test/hooks.on-ready.test.js +2 -2
  100. package/test/hooks.test.js +25 -25
  101. package/test/http-methods/copy.test.js +22 -24
  102. package/test/http-methods/custom-http-methods.test.js +24 -21
  103. package/test/http-methods/get.test.js +97 -84
  104. package/test/http-methods/head.test.js +63 -57
  105. package/test/http-methods/lock.test.js +21 -20
  106. package/test/http-methods/mkcalendar.test.js +31 -27
  107. package/test/http-methods/mkcol.test.js +10 -10
  108. package/test/http-methods/move.test.js +11 -11
  109. package/test/http-methods/propfind.test.js +32 -27
  110. package/test/http-methods/proppatch.test.js +21 -19
  111. package/test/http-methods/report.test.js +32 -27
  112. package/test/http-methods/search.test.js +52 -47
  113. package/test/http-methods/trace.test.js +3 -4
  114. package/test/http-methods/unlock.test.js +10 -10
  115. package/test/http2/closing.test.js +50 -58
  116. package/test/http2/constraint.test.js +47 -50
  117. package/test/http2/head.test.js +18 -19
  118. package/test/http2/missing-http2-module.test.js +4 -5
  119. package/test/http2/plain.test.js +31 -31
  120. package/test/http2/secure-with-fallback.test.js +61 -61
  121. package/test/http2/secure.test.js +28 -31
  122. package/test/http2/unknown-http-method.test.js +13 -14
  123. package/test/https/custom-https-server.test.js +6 -7
  124. package/test/https/https.test.js +78 -78
  125. package/test/imports.test.js +5 -6
  126. package/test/internals/all.test.js +8 -11
  127. package/test/internals/{contentTypeParser.test.js → content-type-parser.test.js} +5 -6
  128. package/test/internals/context.test.js +9 -11
  129. package/test/internals/decorator.test.js +20 -21
  130. package/test/internals/errors.test.js +427 -427
  131. package/test/internals/{handleRequest.test.js → handle-request.test.js} +53 -42
  132. package/test/internals/{hookRunner.test.js → hook-runner.test.js} +99 -100
  133. package/test/internals/hooks.test.js +31 -35
  134. package/test/internals/{initialConfig.test.js → initial-config.test.js} +92 -80
  135. package/test/internals/logger.test.js +28 -28
  136. package/test/internals/plugin.test.js +17 -18
  137. package/test/internals/reply-serialize.test.js +106 -106
  138. package/test/internals/reply.test.js +620 -585
  139. package/test/internals/{reqIdGenFactory.test.js → req-id-gen-factory.test.js} +31 -31
  140. package/test/internals/request-validate.test.js +218 -221
  141. package/test/internals/request.test.js +225 -107
  142. package/test/internals/server.test.js +15 -12
  143. package/test/internals/validation.test.js +35 -36
  144. package/test/{keepAliveTimeout.test.js → keep-alive-timeout.test.js} +9 -10
  145. package/test/listen.5.test.js +9 -9
  146. package/test/{maxRequestsPerSocket.test.js → max-requests-per-socket.test.js} +30 -30
  147. package/test/middleware.test.js +4 -5
  148. package/test/noop-set.test.js +5 -5
  149. package/test/post-empty-body.test.js +18 -11
  150. package/test/pretty-print.test.js +59 -49
  151. package/test/proto-poisoning.test.js +42 -37
  152. package/test/reply-code.test.js +34 -32
  153. package/test/{reply-earlyHints.test.js → reply-early-hints.test.js} +21 -19
  154. package/test/request-error.test.js +122 -0
  155. package/test/request-header-host.test.js +339 -0
  156. package/test/request-id.test.js +31 -25
  157. package/test/{requestTimeout.test.js → request-timeout.test.js} +11 -11
  158. package/test/route.1.test.js +79 -72
  159. package/test/route.2.test.js +17 -16
  160. package/test/route.3.test.js +32 -27
  161. package/test/route.4.test.js +21 -25
  162. package/test/route.5.test.js +45 -64
  163. package/test/route.6.test.js +70 -89
  164. package/test/route.7.test.js +61 -65
  165. package/test/route.8.test.js +80 -18
  166. package/test/router-options.test.js +80 -77
  167. package/test/same-shape.test.js +5 -5
  168. package/test/schema-examples.test.js +72 -38
  169. package/test/serialize-response.test.js +9 -10
  170. package/test/server.test.js +75 -78
  171. package/test/set-error-handler.test.js +2 -3
  172. package/test/stream-serializers.test.js +10 -7
  173. package/test/sync-routes.test.js +18 -18
  174. package/test/test-reporter.mjs +68 -0
  175. package/test/trust-proxy.test.js +51 -45
  176. package/test/type-provider.test.js +8 -6
  177. package/test/types/content-type-parser.test-d.ts +1 -1
  178. package/test/types/fastify.test-d.ts +16 -4
  179. package/test/types/hooks.test-d.ts +2 -1
  180. package/test/types/instance.test-d.ts +13 -13
  181. package/test/types/logger.test-d.ts +2 -2
  182. package/test/types/plugin.test-d.ts +17 -9
  183. package/test/types/register.test-d.ts +22 -6
  184. package/test/types/reply.test-d.ts +1 -1
  185. package/test/types/route.test-d.ts +34 -4
  186. package/test/types/serverFactory.test-d.ts +1 -1
  187. package/test/types/type-provider.test-d.ts +1 -1
  188. package/test/url-rewriting.test.js +35 -38
  189. package/test/{useSemicolonDelimiter.test.js → use-semicolon-delimiter.test.js} +30 -30
  190. package/test/validation-error-handling.test.js +259 -285
  191. package/test/versioned-routes.test.js +126 -113
  192. package/test/web-api.test.js +48 -37
  193. package/test/{wrapThenable.test.js → wrap-thenable.test.js} +10 -9
  194. package/types/hooks.d.ts +2 -1
  195. package/types/instance.d.ts +9 -2
  196. package/types/register.d.ts +12 -3
  197. package/types/reply.d.ts +1 -1
  198. package/types/request.d.ts +2 -6
  199. package/types/serverFactory.d.ts +3 -3
  200. package/types/utils.d.ts +13 -5
  201. package/test/types/import.js +0 -2
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const { test } = require('tap')
3
+ const { test } = require('node:test')
4
4
  const handleRequest = require('../../lib/handleRequest')
5
5
  const internals = require('../../lib/handleRequest')[Symbol.for('internals')]
6
6
  const Request = require('../../lib/request')
@@ -28,14 +28,14 @@ test('handleRequest function - sent reply', t => {
28
28
  const request = {}
29
29
  const reply = { sent: true }
30
30
  const res = handleRequest(null, request, reply)
31
- t.equal(res, undefined)
31
+ t.assert.strictEqual(res, undefined)
32
32
  })
33
33
 
34
34
  test('handleRequest function - invoke with error', t => {
35
35
  t.plan(1)
36
36
  const request = {}
37
37
  const reply = {}
38
- reply.send = (err) => t.equal(err.message, 'Kaboom')
38
+ reply.send = (err) => t.assert.strictEqual(err.message, 'Kaboom')
39
39
  handleRequest(new Error('Kaboom'), request, reply)
40
40
  })
41
41
 
@@ -56,7 +56,7 @@ test('handler function - invalid schema', t => {
56
56
  }
57
57
  }
58
58
  },
59
- errorHandler: { func: () => { t.pass('errorHandler called') } },
59
+ errorHandler: { func: () => { t.assert.ok('errorHandler called') } },
60
60
  handler: () => {},
61
61
  Reply,
62
62
  Request,
@@ -79,13 +79,13 @@ test('handler function - reply', t => {
79
79
  t.plan(3)
80
80
  const res = {}
81
81
  res.end = () => {
82
- t.equal(res.statusCode, 204)
83
- t.pass()
82
+ t.assert.strictEqual(res.statusCode, 204)
83
+ t.assert.ok(true)
84
84
  }
85
85
  res.writeHead = () => {}
86
86
  const context = {
87
87
  handler: (req, reply) => {
88
- t.equal(typeof reply, 'object')
88
+ t.assert.strictEqual(typeof reply, 'object')
89
89
  reply.code(204)
90
90
  reply.send(undefined)
91
91
  },
@@ -110,12 +110,12 @@ test('handler function - preValidationCallback with finished response', t => {
110
110
  // Be sure to check only `writableEnded` where is available
111
111
  res.writableEnded = true
112
112
  res.end = () => {
113
- t.fail()
113
+ t.assert.fail()
114
114
  }
115
115
  res.writeHead = () => {}
116
116
  const context = {
117
117
  handler: (req, reply) => {
118
- t.fail()
118
+ t.assert.fail()
119
119
  reply.send(undefined)
120
120
  },
121
121
  Reply,
@@ -129,25 +129,28 @@ test('handler function - preValidationCallback with finished response', t => {
129
129
  internals.handler({ [kRouteContext]: context }, new Reply(res, { [kRouteContext]: context }))
130
130
  })
131
131
 
132
- test('request should be defined in onSend Hook on post request with content type application/json', t => {
132
+ test('request should be defined in onSend Hook on post request with content type application/json', (t, done) => {
133
133
  t.plan(8)
134
134
  const fastify = require('../..')()
135
135
 
136
+ t.after(() => {
137
+ fastify.close()
138
+ })
139
+
136
140
  fastify.addHook('onSend', (request, reply, payload, done) => {
137
- t.ok(request)
138
- t.ok(request.raw)
139
- t.ok(request.id)
140
- t.ok(request.params)
141
- t.ok(request.query)
141
+ t.assert.ok(request)
142
+ t.assert.ok(request.raw)
143
+ t.assert.ok(request.id)
144
+ t.assert.ok(request.params)
145
+ t.assert.ok(request.query)
142
146
  done()
143
147
  })
144
148
  fastify.post('/', (request, reply) => {
145
149
  reply.send(200)
146
150
  })
147
- fastify.listen({ port: 0 }, err => {
148
- t.error(err)
149
- t.teardown(() => { fastify.close() })
150
151
 
152
+ fastify.listen({ port: 0 }, err => {
153
+ t.assert.ifError(err)
151
154
  sget({
152
155
  method: 'POST',
153
156
  url: 'http://localhost:' + fastify.server.address().port,
@@ -155,30 +158,33 @@ test('request should be defined in onSend Hook on post request with content type
155
158
  'content-type': 'application/json'
156
159
  }
157
160
  }, (err, response, body) => {
158
- t.error(err)
161
+ t.assert.ifError(err)
159
162
  // a 400 error is expected because of no body
160
- t.equal(response.statusCode, 400)
163
+ t.assert.strictEqual(response.statusCode, 400)
164
+ done()
161
165
  })
162
166
  })
163
167
  })
164
168
 
165
- test('request should be defined in onSend Hook on post request with content type application/x-www-form-urlencoded', t => {
169
+ test('request should be defined in onSend Hook on post request with content type application/x-www-form-urlencoded', (t, done) => {
166
170
  t.plan(7)
167
171
  const fastify = require('../..')()
168
172
 
173
+ t.after(() => { fastify.close() })
174
+
169
175
  fastify.addHook('onSend', (request, reply, payload, done) => {
170
- t.ok(request)
171
- t.ok(request.raw)
172
- t.ok(request.params)
173
- t.ok(request.query)
176
+ t.assert.ok(request)
177
+ t.assert.ok(request.raw)
178
+ t.assert.ok(request.params)
179
+ t.assert.ok(request.query)
174
180
  done()
175
181
  })
176
182
  fastify.post('/', (request, reply) => {
177
183
  reply.send(200)
178
184
  })
185
+
179
186
  fastify.listen({ port: 0 }, err => {
180
- t.error(err)
181
- t.teardown(() => { fastify.close() })
187
+ t.assert.ifError(err)
182
188
 
183
189
  sget({
184
190
  method: 'POST',
@@ -187,30 +193,33 @@ test('request should be defined in onSend Hook on post request with content type
187
193
  'content-type': 'application/x-www-form-urlencoded'
188
194
  }
189
195
  }, (err, response, body) => {
190
- t.error(err)
196
+ t.assert.ifError(err)
191
197
  // a 415 error is expected because of missing content type parser
192
- t.equal(response.statusCode, 415)
198
+ t.assert.strictEqual(response.statusCode, 415)
199
+ done()
193
200
  })
194
201
  })
195
202
  })
196
203
 
197
- test('request should be defined in onSend Hook on options request with content type application/x-www-form-urlencoded', t => {
204
+ test('request should be defined in onSend Hook on options request with content type application/x-www-form-urlencoded', (t, done) => {
198
205
  t.plan(7)
199
206
  const fastify = require('../..')()
200
207
 
208
+ t.after(() => { fastify.close() })
209
+
201
210
  fastify.addHook('onSend', (request, reply, payload, done) => {
202
- t.ok(request)
203
- t.ok(request.raw)
204
- t.ok(request.params)
205
- t.ok(request.query)
211
+ t.assert.ok(request)
212
+ t.assert.ok(request.raw)
213
+ t.assert.ok(request.params)
214
+ t.assert.ok(request.query)
206
215
  done()
207
216
  })
208
217
  fastify.options('/', (request, reply) => {
209
218
  reply.send(200)
210
219
  })
220
+
211
221
  fastify.listen({ port: 0 }, err => {
212
- t.error(err)
213
- t.teardown(() => { fastify.close() })
222
+ t.assert.ifError(err)
214
223
 
215
224
  sget({
216
225
  method: 'OPTIONS',
@@ -219,14 +228,15 @@ test('request should be defined in onSend Hook on options request with content t
219
228
  'content-type': 'application/x-www-form-urlencoded'
220
229
  }
221
230
  }, (err, response, body) => {
222
- t.error(err)
231
+ t.assert.ifError(err)
223
232
  // Body parsing skipped, so no body sent
224
- t.equal(response.statusCode, 200)
233
+ t.assert.strictEqual(response.statusCode, 200)
234
+ done()
225
235
  })
226
236
  })
227
237
  })
228
238
 
229
- test('request should respond with an error if an unserialized payload is sent inside an async handler', t => {
239
+ test('request should respond with an error if an unserialized payload is sent inside an async handler', (t, done) => {
230
240
  t.plan(3)
231
241
 
232
242
  const fastify = require('../..')()
@@ -240,13 +250,14 @@ test('request should respond with an error if an unserialized payload is sent in
240
250
  method: 'GET',
241
251
  url: '/'
242
252
  }, (err, res) => {
243
- t.error(err)
244
- t.equal(res.statusCode, 500)
245
- t.strictSame(JSON.parse(res.payload), {
253
+ t.assert.ifError(err)
254
+ t.assert.strictEqual(res.statusCode, 500)
255
+ t.assert.deepStrictEqual(JSON.parse(res.payload), {
246
256
  error: 'Internal Server Error',
247
257
  code: 'FST_ERR_REP_INVALID_PAYLOAD_TYPE',
248
258
  message: 'Attempted to send payload of invalid type \'object\'. Expected a string or Buffer.',
249
259
  statusCode: 500
250
260
  })
261
+ done()
251
262
  })
252
263
  })
@@ -1,7 +1,6 @@
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 { hookRunnerGenerator, onSendHookRunner } = require('../../lib/hooks')
6
5
 
7
6
  test('hookRunner - Basic', t => {
@@ -16,27 +15,27 @@ test('hookRunner - Basic', t => {
16
15
  }
17
16
 
18
17
  function fn1 (a, b, done) {
19
- t.equal(a, 'a')
20
- t.equal(b, 'b')
18
+ t.assert.strictEqual(a, 'a')
19
+ t.assert.strictEqual(b, 'b')
21
20
  done()
22
21
  }
23
22
 
24
23
  function fn2 (a, b, done) {
25
- t.equal(a, 'a')
26
- t.equal(b, 'b')
24
+ t.assert.strictEqual(a, 'a')
25
+ t.assert.strictEqual(b, 'b')
27
26
  done()
28
27
  }
29
28
 
30
29
  function fn3 (a, b, done) {
31
- t.equal(a, 'a')
32
- t.equal(b, 'b')
30
+ t.assert.strictEqual(a, 'a')
31
+ t.assert.strictEqual(b, 'b')
33
32
  done()
34
33
  }
35
34
 
36
35
  function done (err, a, b) {
37
- t.error(err)
38
- t.equal(a, 'a')
39
- t.equal(b, 'b')
36
+ t.assert.ifError(err)
37
+ t.assert.strictEqual(a, 'a')
38
+ t.assert.strictEqual(b, 'b')
40
39
  }
41
40
  })
42
41
 
@@ -52,25 +51,25 @@ test('hookRunner - In case of error should skip to done', t => {
52
51
  }
53
52
 
54
53
  function fn1 (a, b, done) {
55
- t.equal(a, 'a')
56
- t.equal(b, 'b')
54
+ t.assert.strictEqual(a, 'a')
55
+ t.assert.strictEqual(b, 'b')
57
56
  done()
58
57
  }
59
58
 
60
59
  function fn2 (a, b, done) {
61
- t.equal(a, 'a')
62
- t.equal(b, 'b')
60
+ t.assert.strictEqual(a, 'a')
61
+ t.assert.strictEqual(b, 'b')
63
62
  done(new Error('kaboom'))
64
63
  }
65
64
 
66
65
  function fn3 () {
67
- t.fail('We should not be here')
66
+ t.assert.fail('We should not be here')
68
67
  }
69
68
 
70
69
  function done (err, a, b) {
71
- t.equal(err.message, 'kaboom')
72
- t.equal(a, 'a')
73
- t.equal(b, 'b')
70
+ t.assert.strictEqual(err.message, 'kaboom')
71
+ t.assert.strictEqual(a, 'a')
72
+ t.assert.strictEqual(b, 'b')
74
73
  }
75
74
  })
76
75
 
@@ -86,25 +85,25 @@ test('hookRunner - Should handle throw', t => {
86
85
  }
87
86
 
88
87
  function fn1 (a, b, done) {
89
- t.equal(a, 'a')
90
- t.equal(b, 'b')
88
+ t.assert.strictEqual(a, 'a')
89
+ t.assert.strictEqual(b, 'b')
91
90
  done()
92
91
  }
93
92
 
94
93
  function fn2 (a, b, done) {
95
- t.equal(a, 'a')
96
- t.equal(b, 'b')
94
+ t.assert.strictEqual(a, 'a')
95
+ t.assert.strictEqual(b, 'b')
97
96
  throw new Error('kaboom')
98
97
  }
99
98
 
100
99
  function fn3 () {
101
- t.fail('We should not be here')
100
+ t.assert.fail('We should not be here')
102
101
  }
103
102
 
104
103
  function done (err, a, b) {
105
- t.equal(err.message, 'kaboom')
106
- t.equal(a, 'a')
107
- t.equal(b, 'b')
104
+ t.assert.strictEqual(err.message, 'kaboom')
105
+ t.assert.strictEqual(a, 'a')
106
+ t.assert.strictEqual(b, 'b')
108
107
  }
109
108
  })
110
109
 
@@ -120,27 +119,27 @@ test('hookRunner - Should handle promises', t => {
120
119
  }
121
120
 
122
121
  function fn1 (a, b) {
123
- t.equal(a, 'a')
124
- t.equal(b, 'b')
122
+ t.assert.strictEqual(a, 'a')
123
+ t.assert.strictEqual(b, 'b')
125
124
  return Promise.resolve()
126
125
  }
127
126
 
128
127
  function fn2 (a, b) {
129
- t.equal(a, 'a')
130
- t.equal(b, 'b')
128
+ t.assert.strictEqual(a, 'a')
129
+ t.assert.strictEqual(b, 'b')
131
130
  return Promise.resolve()
132
131
  }
133
132
 
134
133
  function fn3 (a, b) {
135
- t.equal(a, 'a')
136
- t.equal(b, 'b')
134
+ t.assert.strictEqual(a, 'a')
135
+ t.assert.strictEqual(b, 'b')
137
136
  return Promise.resolve()
138
137
  }
139
138
 
140
139
  function done (err, a, b) {
141
- t.error(err)
142
- t.equal(a, 'a')
143
- t.equal(b, 'b')
140
+ t.assert.ifError(err)
141
+ t.assert.strictEqual(a, 'a')
142
+ t.assert.strictEqual(b, 'b')
144
143
  }
145
144
  })
146
145
 
@@ -156,25 +155,25 @@ test('hookRunner - In case of error should skip to done (with promises)', t => {
156
155
  }
157
156
 
158
157
  function fn1 (a, b) {
159
- t.equal(a, 'a')
160
- t.equal(b, 'b')
158
+ t.assert.strictEqual(a, 'a')
159
+ t.assert.strictEqual(b, 'b')
161
160
  return Promise.resolve()
162
161
  }
163
162
 
164
163
  function fn2 (a, b) {
165
- t.equal(a, 'a')
166
- t.equal(b, 'b')
164
+ t.assert.strictEqual(a, 'a')
165
+ t.assert.strictEqual(b, 'b')
167
166
  return Promise.reject(new Error('kaboom'))
168
167
  }
169
168
 
170
169
  function fn3 () {
171
- t.fail('We should not be here')
170
+ t.assert.fail('We should not be here')
172
171
  }
173
172
 
174
173
  function done (err, a, b) {
175
- t.equal(err.message, 'kaboom')
176
- t.equal(a, 'a')
177
- t.equal(b, 'b')
174
+ t.assert.strictEqual(err.message, 'kaboom')
175
+ t.assert.strictEqual(a, 'a')
176
+ t.assert.strictEqual(b, 'b')
178
177
  }
179
178
  })
180
179
 
@@ -194,24 +193,24 @@ test('hookRunner - Be able to exit before its natural end', t => {
194
193
  }
195
194
 
196
195
  function fn1 (a, b, done) {
197
- t.equal(a, 'a')
198
- t.equal(b, 'b')
196
+ t.assert.strictEqual(a, 'a')
197
+ t.assert.strictEqual(b, 'b')
199
198
  done()
200
199
  }
201
200
 
202
201
  function fn2 (a, b) {
203
- t.equal(a, 'a')
204
- t.equal(b, 'b')
202
+ t.assert.strictEqual(a, 'a')
203
+ t.assert.strictEqual(b, 'b')
205
204
  shouldStop = true
206
205
  return Promise.resolve()
207
206
  }
208
207
 
209
208
  function fn3 () {
210
- t.fail('this should not be called')
209
+ t.assert.fail('this should not be called')
211
210
  }
212
211
 
213
212
  function done () {
214
- t.fail('this should not be called')
213
+ t.assert.fail('this should not be called')
215
214
  }
216
215
  })
217
216
 
@@ -229,23 +228,23 @@ test('hookRunner - Promises that resolve to a value do not change the state', t
229
228
  }
230
229
 
231
230
  function fn1 (state, b, done) {
232
- t.equal(state, originalState)
231
+ t.assert.strictEqual(state, originalState)
233
232
  return Promise.resolve(null)
234
233
  }
235
234
 
236
235
  function fn2 (state, b, done) {
237
- t.equal(state, originalState)
236
+ t.assert.strictEqual(state, originalState)
238
237
  return Promise.resolve('string')
239
238
  }
240
239
 
241
240
  function fn3 (state, b, done) {
242
- t.equal(state, originalState)
241
+ t.assert.strictEqual(state, originalState)
243
242
  return Promise.resolve({ object: true })
244
243
  }
245
244
 
246
245
  function done (err, state, b) {
247
- t.error(err)
248
- t.equal(state, originalState)
246
+ t.assert.ifError(err)
247
+ t.assert.strictEqual(state, originalState)
249
248
  }
250
249
  })
251
250
 
@@ -259,31 +258,31 @@ test('onSendHookRunner - Basic', t => {
259
258
  onSendHookRunner([fn1, fn2, fn3], originalRequest, originalReply, originalPayload, done)
260
259
 
261
260
  function fn1 (request, reply, payload, done) {
262
- t.same(request, originalRequest)
263
- t.same(reply, originalReply)
264
- t.equal(payload, originalPayload)
261
+ t.assert.deepStrictEqual(request, originalRequest)
262
+ t.assert.deepStrictEqual(reply, originalReply)
263
+ t.assert.strictEqual(payload, originalPayload)
265
264
  done()
266
265
  }
267
266
 
268
267
  function fn2 (request, reply, payload, done) {
269
- t.same(request, originalRequest)
270
- t.same(reply, originalReply)
271
- t.equal(payload, originalPayload)
268
+ t.assert.deepStrictEqual(request, originalRequest)
269
+ t.assert.deepStrictEqual(reply, originalReply)
270
+ t.assert.strictEqual(payload, originalPayload)
272
271
  done()
273
272
  }
274
273
 
275
274
  function fn3 (request, reply, payload, done) {
276
- t.same(request, originalRequest)
277
- t.same(reply, originalReply)
278
- t.equal(payload, originalPayload)
275
+ t.assert.deepStrictEqual(request, originalRequest)
276
+ t.assert.deepStrictEqual(reply, originalReply)
277
+ t.assert.strictEqual(payload, originalPayload)
279
278
  done()
280
279
  }
281
280
 
282
281
  function done (err, request, reply, payload) {
283
- t.error(err)
284
- t.same(request, originalRequest)
285
- t.same(reply, originalReply)
286
- t.equal(payload, originalPayload)
282
+ t.assert.ifError(err)
283
+ t.assert.deepStrictEqual(request, originalRequest)
284
+ t.assert.deepStrictEqual(reply, originalReply)
285
+ t.assert.strictEqual(payload, originalPayload)
287
286
  }
288
287
  })
289
288
 
@@ -300,25 +299,25 @@ test('onSendHookRunner - Can change the payload', t => {
300
299
  onSendHookRunner([fn1, fn2, fn3], originalRequest, originalReply, v1, done)
301
300
 
302
301
  function fn1 (request, reply, payload, done) {
303
- t.same(payload, v1)
302
+ t.assert.deepStrictEqual(payload, v1)
304
303
  done(null, v2)
305
304
  }
306
305
 
307
306
  function fn2 (request, reply, payload, done) {
308
- t.same(payload, v2)
307
+ t.assert.deepStrictEqual(payload, v2)
309
308
  done(null, v3)
310
309
  }
311
310
 
312
311
  function fn3 (request, reply, payload, done) {
313
- t.same(payload, v3)
312
+ t.assert.deepStrictEqual(payload, v3)
314
313
  done(null, v4)
315
314
  }
316
315
 
317
316
  function done (err, request, reply, payload) {
318
- t.error(err)
319
- t.same(request, originalRequest)
320
- t.same(reply, originalReply)
321
- t.same(payload, v4)
317
+ t.assert.ifError(err)
318
+ t.assert.deepStrictEqual(request, originalRequest)
319
+ t.assert.deepStrictEqual(reply, originalReply)
320
+ t.assert.deepStrictEqual(payload, v4)
322
321
  }
323
322
  })
324
323
 
@@ -333,24 +332,24 @@ test('onSendHookRunner - In case of error should skip to done', t => {
333
332
  onSendHookRunner([fn1, fn2, fn3], originalRequest, originalReply, v1, done)
334
333
 
335
334
  function fn1 (request, reply, payload, done) {
336
- t.same(payload, v1)
335
+ t.assert.deepStrictEqual(payload, v1)
337
336
  done(null, v2)
338
337
  }
339
338
 
340
339
  function fn2 (request, reply, payload, done) {
341
- t.same(payload, v2)
340
+ t.assert.deepStrictEqual(payload, v2)
342
341
  done(new Error('kaboom'))
343
342
  }
344
343
 
345
344
  function fn3 () {
346
- t.fail('We should not be here')
345
+ t.assert.fail('We should not be here')
347
346
  }
348
347
 
349
348
  function done (err, request, reply, payload) {
350
- t.equal(err.message, 'kaboom')
351
- t.same(request, originalRequest)
352
- t.same(reply, originalReply)
353
- t.same(payload, v2)
349
+ t.assert.strictEqual(err.message, 'kaboom')
350
+ t.assert.deepStrictEqual(request, originalRequest)
351
+ t.assert.deepStrictEqual(reply, originalReply)
352
+ t.assert.deepStrictEqual(payload, v2)
354
353
  }
355
354
  })
356
355
 
@@ -367,25 +366,25 @@ test('onSendHookRunner - Should handle promises', t => {
367
366
  onSendHookRunner([fn1, fn2, fn3], originalRequest, originalReply, v1, done)
368
367
 
369
368
  function fn1 (request, reply, payload) {
370
- t.same(payload, v1)
369
+ t.assert.deepStrictEqual(payload, v1)
371
370
  return Promise.resolve(v2)
372
371
  }
373
372
 
374
373
  function fn2 (request, reply, payload) {
375
- t.same(payload, v2)
374
+ t.assert.deepStrictEqual(payload, v2)
376
375
  return Promise.resolve(v3)
377
376
  }
378
377
 
379
378
  function fn3 (request, reply, payload) {
380
- t.same(payload, v3)
379
+ t.assert.deepStrictEqual(payload, v3)
381
380
  return Promise.resolve(v4)
382
381
  }
383
382
 
384
383
  function done (err, request, reply, payload) {
385
- t.error(err)
386
- t.same(request, originalRequest)
387
- t.same(reply, originalReply)
388
- t.same(payload, v4)
384
+ t.assert.ifError(err)
385
+ t.assert.deepStrictEqual(request, originalRequest)
386
+ t.assert.deepStrictEqual(reply, originalReply)
387
+ t.assert.deepStrictEqual(payload, v4)
389
388
  }
390
389
  })
391
390
 
@@ -400,24 +399,24 @@ test('onSendHookRunner - In case of error should skip to done (with promises)',
400
399
  onSendHookRunner([fn1, fn2, fn3], originalRequest, originalReply, v1, done)
401
400
 
402
401
  function fn1 (request, reply, payload) {
403
- t.same(payload, v1)
402
+ t.assert.deepStrictEqual(payload, v1)
404
403
  return Promise.resolve(v2)
405
404
  }
406
405
 
407
406
  function fn2 (request, reply, payload) {
408
- t.same(payload, v2)
407
+ t.assert.deepStrictEqual(payload, v2)
409
408
  return Promise.reject(new Error('kaboom'))
410
409
  }
411
410
 
412
411
  function fn3 () {
413
- t.fail('We should not be here')
412
+ t.assert.fail('We should not be here')
414
413
  }
415
414
 
416
415
  function done (err, request, reply, payload) {
417
- t.equal(err.message, 'kaboom')
418
- t.same(request, originalRequest)
419
- t.same(reply, originalReply)
420
- t.same(payload, v2)
416
+ t.assert.strictEqual(err.message, 'kaboom')
417
+ t.assert.deepStrictEqual(request, originalRequest)
418
+ t.assert.deepStrictEqual(reply, originalReply)
419
+ t.assert.deepStrictEqual(payload, v2)
421
420
  }
422
421
  })
423
422
 
@@ -432,19 +431,19 @@ test('onSendHookRunner - Be able to exit before its natural end', t => {
432
431
  onSendHookRunner([fn1, fn2, fn3], originalRequest, originalReply, v1, done)
433
432
 
434
433
  function fn1 (request, reply, payload, done) {
435
- t.same(payload, v1)
434
+ t.assert.deepStrictEqual(payload, v1)
436
435
  done(null, v2)
437
436
  }
438
437
 
439
438
  function fn2 (request, reply, payload) {
440
- t.same(payload, v2)
439
+ t.assert.deepStrictEqual(payload, v2)
441
440
  }
442
441
 
443
442
  function fn3 () {
444
- t.fail('this should not be called')
443
+ t.assert.fail('this should not be called')
445
444
  }
446
445
 
447
446
  function done () {
448
- t.fail('this should not be called')
447
+ t.assert.fail('this should not be called')
449
448
  }
450
449
  })