fastify 5.0.0 → 5.1.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 (138) hide show
  1. package/.borp.yaml +3 -0
  2. package/.vscode/settings.json +22 -0
  3. package/docs/Guides/Ecosystem.md +1 -8
  4. package/docs/Guides/Migration-Guide-V5.md +128 -4
  5. package/docs/Guides/Testing.md +51 -50
  6. package/docs/Guides/Write-Plugin.md +1 -1
  7. package/docs/Reference/ContentTypeParser.md +4 -4
  8. package/docs/Reference/Errors.md +1 -1
  9. package/docs/Reference/Reply.md +1 -5
  10. package/docs/Reference/Request.md +2 -1
  11. package/docs/Reference/Routes.md +9 -6
  12. package/docs/Reference/Server.md +1 -1
  13. package/fastify.d.ts +10 -1
  14. package/fastify.js +8 -6
  15. package/lib/contentTypeParser.js +9 -7
  16. package/lib/context.js +1 -2
  17. package/lib/fourOhFour.js +1 -1
  18. package/lib/{logger.js → logger-factory.js} +70 -122
  19. package/lib/logger-pino.js +68 -0
  20. package/lib/pluginOverride.js +1 -1
  21. package/lib/pluginUtils.js +2 -2
  22. package/lib/reply.js +4 -5
  23. package/lib/request.js +15 -9
  24. package/lib/route.js +23 -22
  25. package/lib/validation.js +2 -2
  26. package/package.json +12 -13
  27. package/test/404s.test.js +675 -629
  28. package/test/500s.test.js +72 -63
  29. package/test/allowUnsafeRegex.test.js +30 -26
  30. package/test/als.test.js +48 -45
  31. package/test/async-await.test.js +148 -134
  32. package/test/async-dispose.test.js +4 -4
  33. package/test/async_hooks.test.js +30 -28
  34. package/test/{bodyLimit.test.js → body-limit.test.js} +61 -58
  35. package/test/buffer.test.js +9 -10
  36. package/test/build/error-serializer.test.js +3 -4
  37. package/test/build/version.test.js +2 -3
  38. package/test/bundler/esbuild/bundler-test.js +10 -9
  39. package/test/bundler/webpack/bundler-test.js +10 -9
  40. package/test/case-insensitive.test.js +31 -28
  41. package/test/chainable.test.js +4 -5
  42. package/test/check.test.js +8 -9
  43. package/test/childLoggerFactory.test.js +56 -19
  44. package/test/client-timeout.test.js +5 -5
  45. package/test/close-pipelining.test.js +6 -7
  46. package/test/conditional-pino.test.js +47 -0
  47. package/test/connectionTimeout.test.js +10 -11
  48. package/test/constrained-routes.test.js +243 -236
  49. package/test/content-parser.test.js +17 -0
  50. package/test/custom-http-server.test.js +16 -20
  51. package/test/diagnostics-channel/404.test.js +15 -15
  52. package/test/diagnostics-channel/async-delay-request.test.js +25 -25
  53. package/test/diagnostics-channel/async-request.test.js +24 -24
  54. package/test/diagnostics-channel/error-before-handler.test.js +4 -5
  55. package/test/diagnostics-channel/error-request.test.js +19 -19
  56. package/test/diagnostics-channel/error-status.test.js +8 -8
  57. package/test/diagnostics-channel/init.test.js +6 -7
  58. package/test/diagnostics-channel/sync-delay-request.test.js +16 -16
  59. package/test/diagnostics-channel/sync-request-reply.test.js +16 -16
  60. package/test/diagnostics-channel/sync-request.test.js +19 -19
  61. package/test/esm/errorCodes.test.mjs +5 -5
  62. package/test/esm/esm.test.mjs +3 -3
  63. package/test/esm/named-exports.mjs +3 -3
  64. package/test/esm/other.mjs +2 -2
  65. package/test/hooks.test.js +6 -6
  66. package/test/http-methods/copy.test.js +22 -24
  67. package/test/http-methods/custom-http-methods.test.js +24 -21
  68. package/test/http-methods/get.test.js +97 -84
  69. package/test/http-methods/head.test.js +63 -54
  70. package/test/http-methods/lock.test.js +21 -20
  71. package/test/http-methods/mkcalendar.test.js +31 -27
  72. package/test/http-methods/mkcol.test.js +10 -10
  73. package/test/http-methods/move.test.js +11 -11
  74. package/test/http-methods/propfind.test.js +32 -27
  75. package/test/http-methods/proppatch.test.js +21 -19
  76. package/test/http-methods/report.test.js +32 -27
  77. package/test/http-methods/search.test.js +52 -47
  78. package/test/http-methods/trace.test.js +3 -4
  79. package/test/http-methods/unlock.test.js +10 -10
  80. package/test/http2/closing.test.js +50 -58
  81. package/test/http2/constraint.test.js +47 -50
  82. package/test/http2/head.test.js +18 -19
  83. package/test/http2/missing-http2-module.test.js +4 -5
  84. package/test/http2/plain.test.js +31 -31
  85. package/test/http2/secure-with-fallback.test.js +61 -61
  86. package/test/http2/secure.test.js +28 -31
  87. package/test/http2/unknown-http-method.test.js +13 -14
  88. package/test/https/custom-https-server.test.js +6 -7
  89. package/test/https/https.test.js +78 -78
  90. package/test/imports.test.js +5 -6
  91. package/test/internals/all.test.js +8 -11
  92. package/test/internals/contentTypeParser.test.js +5 -6
  93. package/test/internals/context.test.js +9 -11
  94. package/test/internals/decorator.test.js +20 -21
  95. package/test/internals/errors.test.js +427 -427
  96. package/test/internals/handleRequest.test.js +53 -42
  97. package/test/internals/hookRunner.test.js +99 -100
  98. package/test/internals/hooks.test.js +31 -35
  99. package/test/internals/initialConfig.test.js +92 -80
  100. package/test/internals/logger.test.js +28 -28
  101. package/test/internals/plugin.test.js +17 -18
  102. package/test/internals/reply-serialize.test.js +106 -106
  103. package/test/internals/reply.test.js +620 -585
  104. package/test/internals/reqIdGenFactory.test.js +31 -31
  105. package/test/internals/request-validate.test.js +218 -221
  106. package/test/internals/request.test.js +225 -107
  107. package/test/internals/server.test.js +15 -12
  108. package/test/internals/validation.test.js +35 -36
  109. package/test/{keepAliveTimeout.test.js → keep-alive-timeout.test.js} +9 -10
  110. package/test/noop-set.test.js +5 -5
  111. package/test/request-error.test.js +122 -0
  112. package/test/request-header-host.test.js +197 -0
  113. package/test/route.1.test.js +79 -72
  114. package/test/route.2.test.js +17 -16
  115. package/test/route.3.test.js +30 -26
  116. package/test/route.4.test.js +21 -25
  117. package/test/route.5.test.js +45 -64
  118. package/test/route.6.test.js +70 -89
  119. package/test/route.7.test.js +61 -65
  120. package/test/route.8.test.js +62 -0
  121. package/test/same-shape.test.js +5 -5
  122. package/test/serialize-response.test.js +9 -10
  123. package/test/server.test.js +67 -70
  124. package/test/test-reporter.mjs +68 -0
  125. package/test/types/fastify.test-d.ts +12 -0
  126. package/test/types/hooks.test-d.ts +2 -1
  127. package/test/types/instance.test-d.ts +10 -12
  128. package/test/types/plugin.test-d.ts +15 -7
  129. package/test/types/register.test-d.ts +20 -4
  130. package/test/types/route.test-d.ts +33 -3
  131. package/test/versioned-routes.test.js +126 -113
  132. package/test/web-api.test.js +48 -37
  133. package/test/wrapThenable.test.js +10 -9
  134. package/types/hooks.d.ts +1 -0
  135. package/types/register.d.ts +12 -3
  136. package/types/request.d.ts +2 -2
  137. package/types/utils.d.ts +10 -2
  138. 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 errors = require('../../lib/errors')
5
5
  const { readFileSync } = require('node:fs')
6
6
  const { resolve } = require('node:path')
@@ -14,7 +14,7 @@ test('should expose 83 errors', t => {
14
14
  counter++
15
15
  }
16
16
  }
17
- t.equal(counter, 83)
17
+ t.assert.strictEqual(counter, 83)
18
18
  })
19
19
 
20
20
  test('ensure name and codes of Errors are identical', t => {
@@ -22,7 +22,7 @@ test('ensure name and codes of Errors are identical', t => {
22
22
  const exportedKeys = Object.keys(errors)
23
23
  for (const key of exportedKeys) {
24
24
  if (errors[key].name === 'FastifyError') {
25
- t.equal(key, new errors[key]().code, key)
25
+ t.assert.strictEqual(key, new errors[key]().code, key)
26
26
  }
27
27
  }
28
28
  })
@@ -30,841 +30,841 @@ test('ensure name and codes of Errors are identical', t => {
30
30
  test('FST_ERR_NOT_FOUND', t => {
31
31
  t.plan(5)
32
32
  const error = new errors.FST_ERR_NOT_FOUND()
33
- t.equal(error.name, 'FastifyError')
34
- t.equal(error.code, 'FST_ERR_NOT_FOUND')
35
- t.equal(error.message, 'Not Found')
36
- t.equal(error.statusCode, 404)
37
- t.ok(error instanceof Error)
33
+ t.assert.strictEqual(error.name, 'FastifyError')
34
+ t.assert.strictEqual(error.code, 'FST_ERR_NOT_FOUND')
35
+ t.assert.strictEqual(error.message, 'Not Found')
36
+ t.assert.strictEqual(error.statusCode, 404)
37
+ t.assert.ok(error instanceof Error)
38
38
  })
39
39
 
40
40
  test('FST_ERR_OPTIONS_NOT_OBJ', t => {
41
41
  t.plan(5)
42
42
  const error = new errors.FST_ERR_OPTIONS_NOT_OBJ()
43
- t.equal(error.name, 'FastifyError')
44
- t.equal(error.code, 'FST_ERR_OPTIONS_NOT_OBJ')
45
- t.equal(error.message, 'Options must be an object')
46
- t.equal(error.statusCode, 500)
47
- t.ok(error instanceof TypeError)
43
+ t.assert.strictEqual(error.name, 'FastifyError')
44
+ t.assert.strictEqual(error.code, 'FST_ERR_OPTIONS_NOT_OBJ')
45
+ t.assert.strictEqual(error.message, 'Options must be an object')
46
+ t.assert.strictEqual(error.statusCode, 500)
47
+ t.assert.ok(error instanceof TypeError)
48
48
  })
49
49
 
50
50
  test('FST_ERR_QSP_NOT_FN', t => {
51
51
  t.plan(5)
52
52
  const error = new errors.FST_ERR_QSP_NOT_FN()
53
- t.equal(error.name, 'FastifyError')
54
- t.equal(error.code, 'FST_ERR_QSP_NOT_FN')
55
- t.equal(error.message, "querystringParser option should be a function, instead got '%s'")
56
- t.equal(error.statusCode, 500)
57
- t.ok(error instanceof TypeError)
53
+ t.assert.strictEqual(error.name, 'FastifyError')
54
+ t.assert.strictEqual(error.code, 'FST_ERR_QSP_NOT_FN')
55
+ t.assert.strictEqual(error.message, "querystringParser option should be a function, instead got '%s'")
56
+ t.assert.strictEqual(error.statusCode, 500)
57
+ t.assert.ok(error instanceof TypeError)
58
58
  })
59
59
 
60
60
  test('FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN', t => {
61
61
  t.plan(5)
62
62
  const error = new errors.FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN()
63
- t.equal(error.name, 'FastifyError')
64
- t.equal(error.code, 'FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN')
65
- t.equal(error.message, "schemaController.bucket option should be a function, instead got '%s'")
66
- t.equal(error.statusCode, 500)
67
- t.ok(error instanceof TypeError)
63
+ t.assert.strictEqual(error.name, 'FastifyError')
64
+ t.assert.strictEqual(error.code, 'FST_ERR_SCHEMA_CONTROLLER_BUCKET_OPT_NOT_FN')
65
+ t.assert.strictEqual(error.message, "schemaController.bucket option should be a function, instead got '%s'")
66
+ t.assert.strictEqual(error.statusCode, 500)
67
+ t.assert.ok(error instanceof TypeError)
68
68
  })
69
69
 
70
70
  test('FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN', t => {
71
71
  t.plan(5)
72
72
  const error = new errors.FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN()
73
- t.equal(error.name, 'FastifyError')
74
- t.equal(error.code, 'FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN')
75
- t.equal(error.message, "schemaErrorFormatter option should be a non async function. Instead got '%s'.")
76
- t.equal(error.statusCode, 500)
77
- t.ok(error instanceof TypeError)
73
+ t.assert.strictEqual(error.name, 'FastifyError')
74
+ t.assert.strictEqual(error.code, 'FST_ERR_SCHEMA_ERROR_FORMATTER_NOT_FN')
75
+ t.assert.strictEqual(error.message, "schemaErrorFormatter option should be a non async function. Instead got '%s'.")
76
+ t.assert.strictEqual(error.statusCode, 500)
77
+ t.assert.ok(error instanceof TypeError)
78
78
  })
79
79
 
80
80
  test('FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ', t => {
81
81
  t.plan(5)
82
82
  const error = new errors.FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ()
83
- t.equal(error.name, 'FastifyError')
84
- t.equal(error.code, 'FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ')
85
- t.equal(error.message, "ajv.customOptions option should be an object, instead got '%s'")
86
- t.equal(error.statusCode, 500)
87
- t.ok(error instanceof TypeError)
83
+ t.assert.strictEqual(error.name, 'FastifyError')
84
+ t.assert.strictEqual(error.code, 'FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_OBJ')
85
+ t.assert.strictEqual(error.message, "ajv.customOptions option should be an object, instead got '%s'")
86
+ t.assert.strictEqual(error.statusCode, 500)
87
+ t.assert.ok(error instanceof TypeError)
88
88
  })
89
89
 
90
90
  test('FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR', t => {
91
91
  t.plan(5)
92
92
  const error = new errors.FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR()
93
- t.equal(error.name, 'FastifyError')
94
- t.equal(error.code, 'FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR')
95
- t.equal(error.message, "ajv.plugins option should be an array, instead got '%s'")
96
- t.equal(error.statusCode, 500)
97
- t.ok(error instanceof TypeError)
93
+ t.assert.strictEqual(error.name, 'FastifyError')
94
+ t.assert.strictEqual(error.code, 'FST_ERR_AJV_CUSTOM_OPTIONS_OPT_NOT_ARR')
95
+ t.assert.strictEqual(error.message, "ajv.plugins option should be an array, instead got '%s'")
96
+ t.assert.strictEqual(error.statusCode, 500)
97
+ t.assert.ok(error instanceof TypeError)
98
98
  })
99
99
 
100
100
  test('FST_ERR_CTP_ALREADY_PRESENT', t => {
101
101
  t.plan(5)
102
102
  const error = new errors.FST_ERR_CTP_ALREADY_PRESENT()
103
- t.equal(error.name, 'FastifyError')
104
- t.equal(error.code, 'FST_ERR_CTP_ALREADY_PRESENT')
105
- t.equal(error.message, "Content type parser '%s' already present.")
106
- t.equal(error.statusCode, 500)
107
- t.ok(error instanceof Error)
103
+ t.assert.strictEqual(error.name, 'FastifyError')
104
+ t.assert.strictEqual(error.code, 'FST_ERR_CTP_ALREADY_PRESENT')
105
+ t.assert.strictEqual(error.message, "Content type parser '%s' already present.")
106
+ t.assert.strictEqual(error.statusCode, 500)
107
+ t.assert.ok(error instanceof Error)
108
108
  })
109
109
 
110
110
  test('FST_ERR_CTP_INVALID_TYPE', t => {
111
111
  t.plan(5)
112
112
  const error = new errors.FST_ERR_CTP_INVALID_TYPE()
113
- t.equal(error.name, 'FastifyError')
114
- t.equal(error.code, 'FST_ERR_CTP_INVALID_TYPE')
115
- t.equal(error.message, 'The content type should be a string or a RegExp')
116
- t.equal(error.statusCode, 500)
117
- t.ok(error instanceof TypeError)
113
+ t.assert.strictEqual(error.name, 'FastifyError')
114
+ t.assert.strictEqual(error.code, 'FST_ERR_CTP_INVALID_TYPE')
115
+ t.assert.strictEqual(error.message, 'The content type should be a string or a RegExp')
116
+ t.assert.strictEqual(error.statusCode, 500)
117
+ t.assert.ok(error instanceof TypeError)
118
118
  })
119
119
 
120
120
  test('FST_ERR_CTP_EMPTY_TYPE', t => {
121
121
  t.plan(5)
122
122
  const error = new errors.FST_ERR_CTP_EMPTY_TYPE()
123
- t.equal(error.name, 'FastifyError')
124
- t.equal(error.code, 'FST_ERR_CTP_EMPTY_TYPE')
125
- t.equal(error.message, 'The content type cannot be an empty string')
126
- t.equal(error.statusCode, 500)
127
- t.ok(error instanceof TypeError)
123
+ t.assert.strictEqual(error.name, 'FastifyError')
124
+ t.assert.strictEqual(error.code, 'FST_ERR_CTP_EMPTY_TYPE')
125
+ t.assert.strictEqual(error.message, 'The content type cannot be an empty string')
126
+ t.assert.strictEqual(error.statusCode, 500)
127
+ t.assert.ok(error instanceof TypeError)
128
128
  })
129
129
 
130
130
  test('FST_ERR_CTP_INVALID_HANDLER', t => {
131
131
  t.plan(5)
132
132
  const error = new errors.FST_ERR_CTP_INVALID_HANDLER()
133
- t.equal(error.name, 'FastifyError')
134
- t.equal(error.code, 'FST_ERR_CTP_INVALID_HANDLER')
135
- t.equal(error.message, 'The content type handler should be a function')
136
- t.equal(error.statusCode, 500)
137
- t.ok(error instanceof TypeError)
133
+ t.assert.strictEqual(error.name, 'FastifyError')
134
+ t.assert.strictEqual(error.code, 'FST_ERR_CTP_INVALID_HANDLER')
135
+ t.assert.strictEqual(error.message, 'The content type handler should be a function')
136
+ t.assert.strictEqual(error.statusCode, 500)
137
+ t.assert.ok(error instanceof TypeError)
138
138
  })
139
139
 
140
140
  test('FST_ERR_CTP_INVALID_PARSE_TYPE', t => {
141
141
  t.plan(5)
142
142
  const error = new errors.FST_ERR_CTP_INVALID_PARSE_TYPE()
143
- t.equal(error.name, 'FastifyError')
144
- t.equal(error.code, 'FST_ERR_CTP_INVALID_PARSE_TYPE')
145
- t.equal(error.message, "The body parser can only parse your data as 'string' or 'buffer', you asked '%s' which is not supported.")
146
- t.equal(error.statusCode, 500)
147
- t.ok(error instanceof TypeError)
143
+ t.assert.strictEqual(error.name, 'FastifyError')
144
+ t.assert.strictEqual(error.code, 'FST_ERR_CTP_INVALID_PARSE_TYPE')
145
+ t.assert.strictEqual(error.message, "The body parser can only parse your data as 'string' or 'buffer', you asked '%s' which is not supported.")
146
+ t.assert.strictEqual(error.statusCode, 500)
147
+ t.assert.ok(error instanceof TypeError)
148
148
  })
149
149
 
150
150
  test('FST_ERR_CTP_BODY_TOO_LARGE', t => {
151
151
  t.plan(5)
152
152
  const error = new errors.FST_ERR_CTP_BODY_TOO_LARGE()
153
- t.equal(error.name, 'FastifyError')
154
- t.equal(error.code, 'FST_ERR_CTP_BODY_TOO_LARGE')
155
- t.equal(error.message, 'Request body is too large')
156
- t.equal(error.statusCode, 413)
157
- t.ok(error instanceof RangeError)
153
+ t.assert.strictEqual(error.name, 'FastifyError')
154
+ t.assert.strictEqual(error.code, 'FST_ERR_CTP_BODY_TOO_LARGE')
155
+ t.assert.strictEqual(error.message, 'Request body is too large')
156
+ t.assert.strictEqual(error.statusCode, 413)
157
+ t.assert.ok(error instanceof RangeError)
158
158
  })
159
159
 
160
160
  test('FST_ERR_CTP_INVALID_MEDIA_TYPE', t => {
161
161
  t.plan(5)
162
162
  const error = new errors.FST_ERR_CTP_INVALID_MEDIA_TYPE()
163
- t.equal(error.name, 'FastifyError')
164
- t.equal(error.code, 'FST_ERR_CTP_INVALID_MEDIA_TYPE')
165
- t.equal(error.message, 'Unsupported Media Type: %s')
166
- t.equal(error.statusCode, 415)
167
- t.ok(error instanceof Error)
163
+ t.assert.strictEqual(error.name, 'FastifyError')
164
+ t.assert.strictEqual(error.code, 'FST_ERR_CTP_INVALID_MEDIA_TYPE')
165
+ t.assert.strictEqual(error.message, 'Unsupported Media Type: %s')
166
+ t.assert.strictEqual(error.statusCode, 415)
167
+ t.assert.ok(error instanceof Error)
168
168
  })
169
169
 
170
170
  test('FST_ERR_CTP_INVALID_CONTENT_LENGTH', t => {
171
171
  t.plan(5)
172
172
  const error = new errors.FST_ERR_CTP_INVALID_CONTENT_LENGTH()
173
- t.equal(error.name, 'FastifyError')
174
- t.equal(error.code, 'FST_ERR_CTP_INVALID_CONTENT_LENGTH')
175
- t.equal(error.message, 'Request body size did not match Content-Length')
176
- t.equal(error.statusCode, 400)
177
- t.ok(error instanceof RangeError)
173
+ t.assert.strictEqual(error.name, 'FastifyError')
174
+ t.assert.strictEqual(error.code, 'FST_ERR_CTP_INVALID_CONTENT_LENGTH')
175
+ t.assert.strictEqual(error.message, 'Request body size did not match Content-Length')
176
+ t.assert.strictEqual(error.statusCode, 400)
177
+ t.assert.ok(error instanceof RangeError)
178
178
  })
179
179
 
180
180
  test('FST_ERR_CTP_EMPTY_JSON_BODY', t => {
181
181
  t.plan(5)
182
182
  const error = new errors.FST_ERR_CTP_EMPTY_JSON_BODY()
183
- t.equal(error.name, 'FastifyError')
184
- t.equal(error.code, 'FST_ERR_CTP_EMPTY_JSON_BODY')
185
- t.equal(error.message, "Body cannot be empty when content-type is set to 'application/json'")
186
- t.equal(error.statusCode, 400)
187
- t.ok(error instanceof Error)
183
+ t.assert.strictEqual(error.name, 'FastifyError')
184
+ t.assert.strictEqual(error.code, 'FST_ERR_CTP_EMPTY_JSON_BODY')
185
+ t.assert.strictEqual(error.message, "Body cannot be empty when content-type is set to 'application/json'")
186
+ t.assert.strictEqual(error.statusCode, 400)
187
+ t.assert.ok(error instanceof Error)
188
188
  })
189
189
 
190
190
  test('FST_ERR_CTP_INSTANCE_ALREADY_STARTED', t => {
191
191
  t.plan(5)
192
192
  const error = new errors.FST_ERR_CTP_INSTANCE_ALREADY_STARTED()
193
- t.equal(error.name, 'FastifyError')
194
- t.equal(error.code, 'FST_ERR_CTP_INSTANCE_ALREADY_STARTED')
195
- t.equal(error.message, 'Cannot call "%s" when fastify instance is already started!')
196
- t.equal(error.statusCode, 400)
197
- t.ok(error instanceof Error)
193
+ t.assert.strictEqual(error.name, 'FastifyError')
194
+ t.assert.strictEqual(error.code, 'FST_ERR_CTP_INSTANCE_ALREADY_STARTED')
195
+ t.assert.strictEqual(error.message, 'Cannot call "%s" when fastify instance is already started!')
196
+ t.assert.strictEqual(error.statusCode, 400)
197
+ t.assert.ok(error instanceof Error)
198
198
  })
199
199
 
200
200
  test('FST_ERR_DEC_ALREADY_PRESENT', t => {
201
201
  t.plan(5)
202
202
  const error = new errors.FST_ERR_DEC_ALREADY_PRESENT()
203
- t.equal(error.name, 'FastifyError')
204
- t.equal(error.code, 'FST_ERR_DEC_ALREADY_PRESENT')
205
- t.equal(error.message, "The decorator '%s' has already been added!")
206
- t.equal(error.statusCode, 500)
207
- t.ok(error instanceof Error)
203
+ t.assert.strictEqual(error.name, 'FastifyError')
204
+ t.assert.strictEqual(error.code, 'FST_ERR_DEC_ALREADY_PRESENT')
205
+ t.assert.strictEqual(error.message, "The decorator '%s' has already been added!")
206
+ t.assert.strictEqual(error.statusCode, 500)
207
+ t.assert.ok(error instanceof Error)
208
208
  })
209
209
 
210
210
  test('FST_ERR_DEC_DEPENDENCY_INVALID_TYPE', t => {
211
211
  t.plan(5)
212
212
  const error = new errors.FST_ERR_DEC_DEPENDENCY_INVALID_TYPE()
213
- t.equal(error.name, 'FastifyError')
214
- t.equal(error.code, 'FST_ERR_DEC_DEPENDENCY_INVALID_TYPE')
215
- t.equal(error.message, "The dependencies of decorator '%s' must be of type Array.")
216
- t.equal(error.statusCode, 500)
217
- t.ok(error instanceof TypeError)
213
+ t.assert.strictEqual(error.name, 'FastifyError')
214
+ t.assert.strictEqual(error.code, 'FST_ERR_DEC_DEPENDENCY_INVALID_TYPE')
215
+ t.assert.strictEqual(error.message, "The dependencies of decorator '%s' must be of type Array.")
216
+ t.assert.strictEqual(error.statusCode, 500)
217
+ t.assert.ok(error instanceof TypeError)
218
218
  })
219
219
 
220
220
  test('FST_ERR_DEC_MISSING_DEPENDENCY', t => {
221
221
  t.plan(5)
222
222
  const error = new errors.FST_ERR_DEC_MISSING_DEPENDENCY()
223
- t.equal(error.name, 'FastifyError')
224
- t.equal(error.code, 'FST_ERR_DEC_MISSING_DEPENDENCY')
225
- t.equal(error.message, "The decorator is missing dependency '%s'.")
226
- t.equal(error.statusCode, 500)
227
- t.ok(error instanceof Error)
223
+ t.assert.strictEqual(error.name, 'FastifyError')
224
+ t.assert.strictEqual(error.code, 'FST_ERR_DEC_MISSING_DEPENDENCY')
225
+ t.assert.strictEqual(error.message, "The decorator is missing dependency '%s'.")
226
+ t.assert.strictEqual(error.statusCode, 500)
227
+ t.assert.ok(error instanceof Error)
228
228
  })
229
229
 
230
230
  test('FST_ERR_DEC_AFTER_START', t => {
231
231
  t.plan(5)
232
232
  const error = new errors.FST_ERR_DEC_AFTER_START()
233
- t.equal(error.name, 'FastifyError')
234
- t.equal(error.code, 'FST_ERR_DEC_AFTER_START')
235
- t.equal(error.message, "The decorator '%s' has been added after start!")
236
- t.equal(error.statusCode, 500)
237
- t.ok(error instanceof Error)
233
+ t.assert.strictEqual(error.name, 'FastifyError')
234
+ t.assert.strictEqual(error.code, 'FST_ERR_DEC_AFTER_START')
235
+ t.assert.strictEqual(error.message, "The decorator '%s' has been added after start!")
236
+ t.assert.strictEqual(error.statusCode, 500)
237
+ t.assert.ok(error instanceof Error)
238
238
  })
239
239
 
240
240
  test('FST_ERR_DEC_REFERENCE_TYPE', t => {
241
241
  t.plan(5)
242
242
  const error = new errors.FST_ERR_DEC_REFERENCE_TYPE()
243
- t.equal(error.name, 'FastifyError')
244
- t.equal(error.code, 'FST_ERR_DEC_REFERENCE_TYPE')
245
- t.equal(error.message, "The decorator '%s' of type '%s' is a reference type. Use the { getter, setter } interface instead.")
246
- t.equal(error.statusCode, 500)
247
- t.ok(error instanceof Error)
243
+ t.assert.strictEqual(error.name, 'FastifyError')
244
+ t.assert.strictEqual(error.code, 'FST_ERR_DEC_REFERENCE_TYPE')
245
+ t.assert.strictEqual(error.message, "The decorator '%s' of type '%s' is a reference type. Use the { getter, setter } interface instead.")
246
+ t.assert.strictEqual(error.statusCode, 500)
247
+ t.assert.ok(error instanceof Error)
248
248
  })
249
249
 
250
250
  test('FST_ERR_HOOK_INVALID_TYPE', t => {
251
251
  t.plan(5)
252
252
  const error = new errors.FST_ERR_HOOK_INVALID_TYPE()
253
- t.equal(error.name, 'FastifyError')
254
- t.equal(error.code, 'FST_ERR_HOOK_INVALID_TYPE')
255
- t.equal(error.message, 'The hook name must be a string')
256
- t.equal(error.statusCode, 500)
257
- t.ok(error instanceof TypeError)
253
+ t.assert.strictEqual(error.name, 'FastifyError')
254
+ t.assert.strictEqual(error.code, 'FST_ERR_HOOK_INVALID_TYPE')
255
+ t.assert.strictEqual(error.message, 'The hook name must be a string')
256
+ t.assert.strictEqual(error.statusCode, 500)
257
+ t.assert.ok(error instanceof TypeError)
258
258
  })
259
259
 
260
260
  test('FST_ERR_HOOK_INVALID_HANDLER', t => {
261
261
  t.plan(5)
262
262
  const error = new errors.FST_ERR_HOOK_INVALID_HANDLER()
263
- t.equal(error.name, 'FastifyError')
264
- t.equal(error.code, 'FST_ERR_HOOK_INVALID_HANDLER')
265
- t.equal(error.message, '%s hook should be a function, instead got %s')
266
- t.equal(error.statusCode, 500)
267
- t.ok(error instanceof TypeError)
263
+ t.assert.strictEqual(error.name, 'FastifyError')
264
+ t.assert.strictEqual(error.code, 'FST_ERR_HOOK_INVALID_HANDLER')
265
+ t.assert.strictEqual(error.message, '%s hook should be a function, instead got %s')
266
+ t.assert.strictEqual(error.statusCode, 500)
267
+ t.assert.ok(error instanceof TypeError)
268
268
  })
269
269
 
270
270
  test('FST_ERR_HOOK_INVALID_ASYNC_HANDLER', t => {
271
271
  t.plan(5)
272
272
  const error = new errors.FST_ERR_HOOK_INVALID_ASYNC_HANDLER()
273
- t.equal(error.name, 'FastifyError')
274
- t.equal(error.code, 'FST_ERR_HOOK_INVALID_ASYNC_HANDLER')
275
- t.equal(error.message, "Async function has too many arguments. Async hooks should not use the 'done' argument.")
276
- t.equal(error.statusCode, 500)
277
- t.ok(error instanceof TypeError)
273
+ t.assert.strictEqual(error.name, 'FastifyError')
274
+ t.assert.strictEqual(error.code, 'FST_ERR_HOOK_INVALID_ASYNC_HANDLER')
275
+ t.assert.strictEqual(error.message, "Async function has too many arguments. Async hooks should not use the 'done' argument.")
276
+ t.assert.strictEqual(error.statusCode, 500)
277
+ t.assert.ok(error instanceof TypeError)
278
278
  })
279
279
 
280
280
  test('FST_ERR_HOOK_NOT_SUPPORTED', t => {
281
281
  t.plan(5)
282
282
  const error = new errors.FST_ERR_HOOK_NOT_SUPPORTED()
283
- t.equal(error.name, 'FastifyError')
284
- t.equal(error.code, 'FST_ERR_HOOK_NOT_SUPPORTED')
285
- t.equal(error.message, '%s hook not supported!')
286
- t.equal(error.statusCode, 500)
287
- t.ok(error instanceof TypeError)
283
+ t.assert.strictEqual(error.name, 'FastifyError')
284
+ t.assert.strictEqual(error.code, 'FST_ERR_HOOK_NOT_SUPPORTED')
285
+ t.assert.strictEqual(error.message, '%s hook not supported!')
286
+ t.assert.strictEqual(error.statusCode, 500)
287
+ t.assert.ok(error instanceof TypeError)
288
288
  })
289
289
 
290
290
  test('FST_ERR_MISSING_MIDDLEWARE', t => {
291
291
  t.plan(5)
292
292
  const error = new errors.FST_ERR_MISSING_MIDDLEWARE()
293
- t.equal(error.name, 'FastifyError')
294
- t.equal(error.code, 'FST_ERR_MISSING_MIDDLEWARE')
295
- t.equal(error.message, 'You must register a plugin for handling middlewares, visit fastify.dev/docs/latest/Reference/Middleware/ for more info.')
296
- t.equal(error.statusCode, 500)
297
- t.ok(error instanceof Error)
293
+ t.assert.strictEqual(error.name, 'FastifyError')
294
+ t.assert.strictEqual(error.code, 'FST_ERR_MISSING_MIDDLEWARE')
295
+ t.assert.strictEqual(error.message, 'You must register a plugin for handling middlewares, visit fastify.dev/docs/latest/Reference/Middleware/ for more info.')
296
+ t.assert.strictEqual(error.statusCode, 500)
297
+ t.assert.ok(error instanceof Error)
298
298
  })
299
299
 
300
300
  test('FST_ERR_HOOK_TIMEOUT', t => {
301
301
  t.plan(5)
302
302
  const error = new errors.FST_ERR_HOOK_TIMEOUT()
303
- t.equal(error.name, 'FastifyError')
304
- t.equal(error.code, 'FST_ERR_HOOK_TIMEOUT')
305
- t.equal(error.message, "A callback for '%s' hook timed out. You may have forgotten to call 'done' function or to resolve a Promise")
306
- t.equal(error.statusCode, 500)
307
- t.ok(error instanceof Error)
303
+ t.assert.strictEqual(error.name, 'FastifyError')
304
+ t.assert.strictEqual(error.code, 'FST_ERR_HOOK_TIMEOUT')
305
+ t.assert.strictEqual(error.message, "A callback for '%s' hook timed out. You may have forgotten to call 'done' function or to resolve a Promise")
306
+ t.assert.strictEqual(error.statusCode, 500)
307
+ t.assert.ok(error instanceof Error)
308
308
  })
309
309
 
310
310
  test('FST_ERR_LOG_INVALID_DESTINATION', t => {
311
311
  t.plan(5)
312
312
  const error = new errors.FST_ERR_LOG_INVALID_DESTINATION()
313
- t.equal(error.name, 'FastifyError')
314
- t.equal(error.code, 'FST_ERR_LOG_INVALID_DESTINATION')
315
- t.equal(error.message, 'Cannot specify both logger.stream and logger.file options')
316
- t.equal(error.statusCode, 500)
317
- t.ok(error instanceof Error)
313
+ t.assert.strictEqual(error.name, 'FastifyError')
314
+ t.assert.strictEqual(error.code, 'FST_ERR_LOG_INVALID_DESTINATION')
315
+ t.assert.strictEqual(error.message, 'Cannot specify both logger.stream and logger.file options')
316
+ t.assert.strictEqual(error.statusCode, 500)
317
+ t.assert.ok(error instanceof Error)
318
318
  })
319
319
 
320
320
  test('FST_ERR_LOG_INVALID_LOGGER', t => {
321
321
  t.plan(5)
322
322
  const error = new errors.FST_ERR_LOG_INVALID_LOGGER()
323
- t.equal(error.name, 'FastifyError')
324
- t.equal(error.code, 'FST_ERR_LOG_INVALID_LOGGER')
325
- t.equal(error.message, "Invalid logger object provided. The logger instance should have these functions(s): '%s'.")
326
- t.equal(error.statusCode, 500)
327
- t.ok(error instanceof TypeError)
323
+ t.assert.strictEqual(error.name, 'FastifyError')
324
+ t.assert.strictEqual(error.code, 'FST_ERR_LOG_INVALID_LOGGER')
325
+ t.assert.strictEqual(error.message, "Invalid logger object provided. The logger instance should have these functions(s): '%s'.")
326
+ t.assert.strictEqual(error.statusCode, 500)
327
+ t.assert.ok(error instanceof TypeError)
328
328
  })
329
329
 
330
330
  test('FST_ERR_LOG_INVALID_LOGGER_INSTANCE', t => {
331
331
  t.plan(5)
332
332
  const error = new errors.FST_ERR_LOG_INVALID_LOGGER_INSTANCE()
333
- t.equal(error.name, 'FastifyError')
334
- t.equal(error.code, 'FST_ERR_LOG_INVALID_LOGGER_INSTANCE')
335
- t.equal(error.message, 'loggerInstance only accepts a logger instance.')
336
- t.equal(error.statusCode, 500)
337
- t.ok(error instanceof TypeError)
333
+ t.assert.strictEqual(error.name, 'FastifyError')
334
+ t.assert.strictEqual(error.code, 'FST_ERR_LOG_INVALID_LOGGER_INSTANCE')
335
+ t.assert.strictEqual(error.message, 'loggerInstance only accepts a logger instance.')
336
+ t.assert.strictEqual(error.statusCode, 500)
337
+ t.assert.ok(error instanceof TypeError)
338
338
  })
339
339
 
340
340
  test('FST_ERR_LOG_INVALID_LOGGER_CONFIG', t => {
341
341
  t.plan(5)
342
342
  const error = new errors.FST_ERR_LOG_INVALID_LOGGER_CONFIG()
343
- t.equal(error.name, 'FastifyError')
344
- t.equal(error.code, 'FST_ERR_LOG_INVALID_LOGGER_CONFIG')
345
- t.equal(error.message, 'logger options only accepts a configuration object.')
346
- t.equal(error.statusCode, 500)
347
- t.ok(error instanceof TypeError)
343
+ t.assert.strictEqual(error.name, 'FastifyError')
344
+ t.assert.strictEqual(error.code, 'FST_ERR_LOG_INVALID_LOGGER_CONFIG')
345
+ t.assert.strictEqual(error.message, 'logger options only accepts a configuration object.')
346
+ t.assert.strictEqual(error.statusCode, 500)
347
+ t.assert.ok(error instanceof TypeError)
348
348
  })
349
349
 
350
350
  test('FST_ERR_LOG_LOGGER_AND_LOGGER_INSTANCE_PROVIDED', t => {
351
351
  t.plan(5)
352
352
  const error = new errors.FST_ERR_LOG_LOGGER_AND_LOGGER_INSTANCE_PROVIDED()
353
- t.equal(error.name, 'FastifyError')
354
- t.equal(error.code, 'FST_ERR_LOG_LOGGER_AND_LOGGER_INSTANCE_PROVIDED')
355
- t.equal(error.message, 'You cannot provide both logger and loggerInstance. Please provide only one.')
356
- t.equal(error.statusCode, 500)
357
- t.ok(error instanceof TypeError)
353
+ t.assert.strictEqual(error.name, 'FastifyError')
354
+ t.assert.strictEqual(error.code, 'FST_ERR_LOG_LOGGER_AND_LOGGER_INSTANCE_PROVIDED')
355
+ t.assert.strictEqual(error.message, 'You cannot provide both logger and loggerInstance. Please provide only one.')
356
+ t.assert.strictEqual(error.statusCode, 500)
357
+ t.assert.ok(error instanceof TypeError)
358
358
  })
359
359
 
360
360
  test('FST_ERR_REP_INVALID_PAYLOAD_TYPE', t => {
361
361
  t.plan(5)
362
362
  const error = new errors.FST_ERR_REP_INVALID_PAYLOAD_TYPE()
363
- t.equal(error.name, 'FastifyError')
364
- t.equal(error.code, 'FST_ERR_REP_INVALID_PAYLOAD_TYPE')
365
- t.equal(error.message, "Attempted to send payload of invalid type '%s'. Expected a string or Buffer.")
366
- t.equal(error.statusCode, 500)
367
- t.ok(error instanceof TypeError)
363
+ t.assert.strictEqual(error.name, 'FastifyError')
364
+ t.assert.strictEqual(error.code, 'FST_ERR_REP_INVALID_PAYLOAD_TYPE')
365
+ t.assert.strictEqual(error.message, "Attempted to send payload of invalid type '%s'. Expected a string or Buffer.")
366
+ t.assert.strictEqual(error.statusCode, 500)
367
+ t.assert.ok(error instanceof TypeError)
368
368
  })
369
369
 
370
370
  test('FST_ERR_REP_RESPONSE_BODY_CONSUMED', t => {
371
371
  t.plan(5)
372
372
  const error = new errors.FST_ERR_REP_RESPONSE_BODY_CONSUMED()
373
- t.equal(error.name, 'FastifyError')
374
- t.equal(error.code, 'FST_ERR_REP_RESPONSE_BODY_CONSUMED')
375
- t.equal(error.message, 'Response.body is already consumed.')
376
- t.equal(error.statusCode, 500)
377
- t.ok(error instanceof Error)
373
+ t.assert.strictEqual(error.name, 'FastifyError')
374
+ t.assert.strictEqual(error.code, 'FST_ERR_REP_RESPONSE_BODY_CONSUMED')
375
+ t.assert.strictEqual(error.message, 'Response.body is already consumed.')
376
+ t.assert.strictEqual(error.statusCode, 500)
377
+ t.assert.ok(error instanceof Error)
378
378
  })
379
379
 
380
380
  test('FST_ERR_REP_ALREADY_SENT', t => {
381
381
  t.plan(5)
382
382
  const error = new errors.FST_ERR_REP_ALREADY_SENT('/hello', 'GET')
383
- t.equal(error.name, 'FastifyError')
384
- t.equal(error.code, 'FST_ERR_REP_ALREADY_SENT')
385
- t.equal(error.message, 'Reply was already sent, did you forget to "return reply" in "/hello" (GET)?')
386
- t.equal(error.statusCode, 500)
387
- t.ok(error instanceof Error)
383
+ t.assert.strictEqual(error.name, 'FastifyError')
384
+ t.assert.strictEqual(error.code, 'FST_ERR_REP_ALREADY_SENT')
385
+ t.assert.strictEqual(error.message, 'Reply was already sent, did you forget to "return reply" in "/hello" (GET)?')
386
+ t.assert.strictEqual(error.statusCode, 500)
387
+ t.assert.ok(error instanceof Error)
388
388
  })
389
389
 
390
390
  test('FST_ERR_REP_SENT_VALUE', t => {
391
391
  t.plan(5)
392
392
  const error = new errors.FST_ERR_REP_SENT_VALUE()
393
- t.equal(error.name, 'FastifyError')
394
- t.equal(error.code, 'FST_ERR_REP_SENT_VALUE')
395
- t.equal(error.message, 'The only possible value for reply.sent is true.')
396
- t.equal(error.statusCode, 500)
397
- t.ok(error instanceof TypeError)
393
+ t.assert.strictEqual(error.name, 'FastifyError')
394
+ t.assert.strictEqual(error.code, 'FST_ERR_REP_SENT_VALUE')
395
+ t.assert.strictEqual(error.message, 'The only possible value for reply.sent is true.')
396
+ t.assert.strictEqual(error.statusCode, 500)
397
+ t.assert.ok(error instanceof TypeError)
398
398
  })
399
399
 
400
400
  test('FST_ERR_SEND_INSIDE_ONERR', t => {
401
401
  t.plan(5)
402
402
  const error = new errors.FST_ERR_SEND_INSIDE_ONERR()
403
- t.equal(error.name, 'FastifyError')
404
- t.equal(error.code, 'FST_ERR_SEND_INSIDE_ONERR')
405
- t.equal(error.message, 'You cannot use `send` inside the `onError` hook')
406
- t.equal(error.statusCode, 500)
407
- t.ok(error instanceof Error)
403
+ t.assert.strictEqual(error.name, 'FastifyError')
404
+ t.assert.strictEqual(error.code, 'FST_ERR_SEND_INSIDE_ONERR')
405
+ t.assert.strictEqual(error.message, 'You cannot use `send` inside the `onError` hook')
406
+ t.assert.strictEqual(error.statusCode, 500)
407
+ t.assert.ok(error instanceof Error)
408
408
  })
409
409
 
410
410
  test('FST_ERR_SEND_UNDEFINED_ERR', t => {
411
411
  t.plan(5)
412
412
  const error = new errors.FST_ERR_SEND_UNDEFINED_ERR()
413
- t.equal(error.name, 'FastifyError')
414
- t.equal(error.code, 'FST_ERR_SEND_UNDEFINED_ERR')
415
- t.equal(error.message, 'Undefined error has occurred')
416
- t.equal(error.statusCode, 500)
417
- t.ok(error instanceof Error)
413
+ t.assert.strictEqual(error.name, 'FastifyError')
414
+ t.assert.strictEqual(error.code, 'FST_ERR_SEND_UNDEFINED_ERR')
415
+ t.assert.strictEqual(error.message, 'Undefined error has occurred')
416
+ t.assert.strictEqual(error.statusCode, 500)
417
+ t.assert.ok(error instanceof Error)
418
418
  })
419
419
 
420
420
  test('FST_ERR_BAD_STATUS_CODE', t => {
421
421
  t.plan(5)
422
422
  const error = new errors.FST_ERR_BAD_STATUS_CODE()
423
- t.equal(error.name, 'FastifyError')
424
- t.equal(error.code, 'FST_ERR_BAD_STATUS_CODE')
425
- t.equal(error.message, 'Called reply with an invalid status code: %s')
426
- t.equal(error.statusCode, 500)
427
- t.ok(error instanceof Error)
423
+ t.assert.strictEqual(error.name, 'FastifyError')
424
+ t.assert.strictEqual(error.code, 'FST_ERR_BAD_STATUS_CODE')
425
+ t.assert.strictEqual(error.message, 'Called reply with an invalid status code: %s')
426
+ t.assert.strictEqual(error.statusCode, 500)
427
+ t.assert.ok(error instanceof Error)
428
428
  })
429
429
 
430
430
  test('FST_ERR_BAD_TRAILER_NAME', t => {
431
431
  t.plan(5)
432
432
  const error = new errors.FST_ERR_BAD_TRAILER_NAME()
433
- t.equal(error.name, 'FastifyError')
434
- t.equal(error.code, 'FST_ERR_BAD_TRAILER_NAME')
435
- t.equal(error.message, 'Called reply.trailer with an invalid header name: %s')
436
- t.equal(error.statusCode, 500)
437
- t.ok(error instanceof Error)
433
+ t.assert.strictEqual(error.name, 'FastifyError')
434
+ t.assert.strictEqual(error.code, 'FST_ERR_BAD_TRAILER_NAME')
435
+ t.assert.strictEqual(error.message, 'Called reply.trailer with an invalid header name: %s')
436
+ t.assert.strictEqual(error.statusCode, 500)
437
+ t.assert.ok(error instanceof Error)
438
438
  })
439
439
 
440
440
  test('FST_ERR_BAD_TRAILER_VALUE', t => {
441
441
  t.plan(5)
442
442
  const error = new errors.FST_ERR_BAD_TRAILER_VALUE()
443
- t.equal(error.name, 'FastifyError')
444
- t.equal(error.code, 'FST_ERR_BAD_TRAILER_VALUE')
445
- t.equal(error.message, "Called reply.trailer('%s', fn) with an invalid type: %s. Expected a function.")
446
- t.equal(error.statusCode, 500)
447
- t.ok(error instanceof Error)
443
+ t.assert.strictEqual(error.name, 'FastifyError')
444
+ t.assert.strictEqual(error.code, 'FST_ERR_BAD_TRAILER_VALUE')
445
+ t.assert.strictEqual(error.message, "Called reply.trailer('%s', fn) with an invalid type: %s. Expected a function.")
446
+ t.assert.strictEqual(error.statusCode, 500)
447
+ t.assert.ok(error instanceof Error)
448
448
  })
449
449
 
450
450
  test('FST_ERR_FAILED_ERROR_SERIALIZATION', t => {
451
451
  t.plan(5)
452
452
  const error = new errors.FST_ERR_FAILED_ERROR_SERIALIZATION()
453
- t.equal(error.name, 'FastifyError')
454
- t.equal(error.code, 'FST_ERR_FAILED_ERROR_SERIALIZATION')
455
- t.equal(error.message, 'Failed to serialize an error. Error: %s. Original error: %s')
456
- t.equal(error.statusCode, 500)
457
- t.ok(error instanceof Error)
453
+ t.assert.strictEqual(error.name, 'FastifyError')
454
+ t.assert.strictEqual(error.code, 'FST_ERR_FAILED_ERROR_SERIALIZATION')
455
+ t.assert.strictEqual(error.message, 'Failed to serialize an error. Error: %s. Original error: %s')
456
+ t.assert.strictEqual(error.statusCode, 500)
457
+ t.assert.ok(error instanceof Error)
458
458
  })
459
459
 
460
460
  test('FST_ERR_MISSING_SERIALIZATION_FN', t => {
461
461
  t.plan(5)
462
462
  const error = new errors.FST_ERR_MISSING_SERIALIZATION_FN()
463
- t.equal(error.name, 'FastifyError')
464
- t.equal(error.code, 'FST_ERR_MISSING_SERIALIZATION_FN')
465
- t.equal(error.message, 'Missing serialization function. Key "%s"')
466
- t.equal(error.statusCode, 500)
467
- t.ok(error instanceof Error)
463
+ t.assert.strictEqual(error.name, 'FastifyError')
464
+ t.assert.strictEqual(error.code, 'FST_ERR_MISSING_SERIALIZATION_FN')
465
+ t.assert.strictEqual(error.message, 'Missing serialization function. Key "%s"')
466
+ t.assert.strictEqual(error.statusCode, 500)
467
+ t.assert.ok(error instanceof Error)
468
468
  })
469
469
 
470
470
  test('FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN', t => {
471
471
  t.plan(5)
472
472
  const error = new errors.FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN()
473
- t.equal(error.name, 'FastifyError')
474
- t.equal(error.code, 'FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN')
475
- t.equal(error.message, 'Missing serialization function. Key "%s:%s"')
476
- t.equal(error.statusCode, 500)
477
- t.ok(error instanceof Error)
473
+ t.assert.strictEqual(error.name, 'FastifyError')
474
+ t.assert.strictEqual(error.code, 'FST_ERR_MISSING_CONTENTTYPE_SERIALIZATION_FN')
475
+ t.assert.strictEqual(error.message, 'Missing serialization function. Key "%s:%s"')
476
+ t.assert.strictEqual(error.statusCode, 500)
477
+ t.assert.ok(error instanceof Error)
478
478
  })
479
479
 
480
480
  test('FST_ERR_REQ_INVALID_VALIDATION_INVOCATION', t => {
481
481
  t.plan(5)
482
482
  const error = new errors.FST_ERR_REQ_INVALID_VALIDATION_INVOCATION()
483
- t.equal(error.name, 'FastifyError')
484
- t.equal(error.code, 'FST_ERR_REQ_INVALID_VALIDATION_INVOCATION')
485
- t.equal(error.message, 'Invalid validation invocation. Missing validation function for HTTP part "%s" nor schema provided.')
486
- t.equal(error.statusCode, 500)
487
- t.ok(error instanceof Error)
483
+ t.assert.strictEqual(error.name, 'FastifyError')
484
+ t.assert.strictEqual(error.code, 'FST_ERR_REQ_INVALID_VALIDATION_INVOCATION')
485
+ t.assert.strictEqual(error.message, 'Invalid validation invocation. Missing validation function for HTTP part "%s" nor schema provided.')
486
+ t.assert.strictEqual(error.statusCode, 500)
487
+ t.assert.ok(error instanceof Error)
488
488
  })
489
489
 
490
490
  test('FST_ERR_SCH_MISSING_ID', t => {
491
491
  t.plan(5)
492
492
  const error = new errors.FST_ERR_SCH_MISSING_ID()
493
- t.equal(error.name, 'FastifyError')
494
- t.equal(error.code, 'FST_ERR_SCH_MISSING_ID')
495
- t.equal(error.message, 'Missing schema $id property')
496
- t.equal(error.statusCode, 500)
497
- t.ok(error instanceof Error)
493
+ t.assert.strictEqual(error.name, 'FastifyError')
494
+ t.assert.strictEqual(error.code, 'FST_ERR_SCH_MISSING_ID')
495
+ t.assert.strictEqual(error.message, 'Missing schema $id property')
496
+ t.assert.strictEqual(error.statusCode, 500)
497
+ t.assert.ok(error instanceof Error)
498
498
  })
499
499
 
500
500
  test('FST_ERR_SCH_ALREADY_PRESENT', t => {
501
501
  t.plan(5)
502
502
  const error = new errors.FST_ERR_SCH_ALREADY_PRESENT()
503
- t.equal(error.name, 'FastifyError')
504
- t.equal(error.code, 'FST_ERR_SCH_ALREADY_PRESENT')
505
- t.equal(error.message, "Schema with id '%s' already declared!")
506
- t.equal(error.statusCode, 500)
507
- t.ok(error instanceof Error)
503
+ t.assert.strictEqual(error.name, 'FastifyError')
504
+ t.assert.strictEqual(error.code, 'FST_ERR_SCH_ALREADY_PRESENT')
505
+ t.assert.strictEqual(error.message, "Schema with id '%s' already declared!")
506
+ t.assert.strictEqual(error.statusCode, 500)
507
+ t.assert.ok(error instanceof Error)
508
508
  })
509
509
 
510
510
  test('FST_ERR_SCH_CONTENT_MISSING_SCHEMA', t => {
511
511
  t.plan(5)
512
512
  const error = new errors.FST_ERR_SCH_CONTENT_MISSING_SCHEMA()
513
- t.equal(error.name, 'FastifyError')
514
- t.equal(error.code, 'FST_ERR_SCH_CONTENT_MISSING_SCHEMA')
515
- t.equal(error.message, "Schema is missing for the content type '%s'")
516
- t.equal(error.statusCode, 500)
517
- t.ok(error instanceof Error)
513
+ t.assert.strictEqual(error.name, 'FastifyError')
514
+ t.assert.strictEqual(error.code, 'FST_ERR_SCH_CONTENT_MISSING_SCHEMA')
515
+ t.assert.strictEqual(error.message, "Schema is missing for the content type '%s'")
516
+ t.assert.strictEqual(error.statusCode, 500)
517
+ t.assert.ok(error instanceof Error)
518
518
  })
519
519
 
520
520
  test('FST_ERR_SCH_DUPLICATE', t => {
521
521
  t.plan(5)
522
522
  const error = new errors.FST_ERR_SCH_DUPLICATE()
523
- t.equal(error.name, 'FastifyError')
524
- t.equal(error.code, 'FST_ERR_SCH_DUPLICATE')
525
- t.equal(error.message, "Schema with '%s' already present!")
526
- t.equal(error.statusCode, 500)
527
- t.ok(error instanceof Error)
523
+ t.assert.strictEqual(error.name, 'FastifyError')
524
+ t.assert.strictEqual(error.code, 'FST_ERR_SCH_DUPLICATE')
525
+ t.assert.strictEqual(error.message, "Schema with '%s' already present!")
526
+ t.assert.strictEqual(error.statusCode, 500)
527
+ t.assert.ok(error instanceof Error)
528
528
  })
529
529
 
530
530
  test('FST_ERR_SCH_VALIDATION_BUILD', t => {
531
531
  t.plan(5)
532
532
  const error = new errors.FST_ERR_SCH_VALIDATION_BUILD()
533
- t.equal(error.name, 'FastifyError')
534
- t.equal(error.code, 'FST_ERR_SCH_VALIDATION_BUILD')
535
- t.equal(error.message, 'Failed building the validation schema for %s: %s, due to error %s')
536
- t.equal(error.statusCode, 500)
537
- t.ok(error instanceof Error)
533
+ t.assert.strictEqual(error.name, 'FastifyError')
534
+ t.assert.strictEqual(error.code, 'FST_ERR_SCH_VALIDATION_BUILD')
535
+ t.assert.strictEqual(error.message, 'Failed building the validation schema for %s: %s, due to error %s')
536
+ t.assert.strictEqual(error.statusCode, 500)
537
+ t.assert.ok(error instanceof Error)
538
538
  })
539
539
 
540
540
  test('FST_ERR_SCH_SERIALIZATION_BUILD', t => {
541
541
  t.plan(5)
542
542
  const error = new errors.FST_ERR_SCH_SERIALIZATION_BUILD()
543
- t.equal(error.name, 'FastifyError')
544
- t.equal(error.code, 'FST_ERR_SCH_SERIALIZATION_BUILD')
545
- t.equal(error.message, 'Failed building the serialization schema for %s: %s, due to error %s')
546
- t.equal(error.statusCode, 500)
547
- t.ok(error instanceof Error)
543
+ t.assert.strictEqual(error.name, 'FastifyError')
544
+ t.assert.strictEqual(error.code, 'FST_ERR_SCH_SERIALIZATION_BUILD')
545
+ t.assert.strictEqual(error.message, 'Failed building the serialization schema for %s: %s, due to error %s')
546
+ t.assert.strictEqual(error.statusCode, 500)
547
+ t.assert.ok(error instanceof Error)
548
548
  })
549
549
 
550
550
  test('FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX', t => {
551
551
  t.plan(5)
552
552
  const error = new errors.FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX()
553
- t.equal(error.name, 'FastifyError')
554
- t.equal(error.code, 'FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX')
555
- t.equal(error.message, 'response schemas should be nested under a valid status code, e.g { 2xx: { type: "object" } }')
556
- t.equal(error.statusCode, 500)
557
- t.ok(error instanceof Error)
553
+ t.assert.strictEqual(error.name, 'FastifyError')
554
+ t.assert.strictEqual(error.code, 'FST_ERR_SCH_RESPONSE_SCHEMA_NOT_NESTED_2XX')
555
+ t.assert.strictEqual(error.message, 'response schemas should be nested under a valid status code, e.g { 2xx: { type: "object" } }')
556
+ t.assert.strictEqual(error.statusCode, 500)
557
+ t.assert.ok(error instanceof Error)
558
558
  })
559
559
 
560
560
  test('FST_ERR_HTTP2_INVALID_VERSION', t => {
561
561
  t.plan(5)
562
562
  const error = new errors.FST_ERR_HTTP2_INVALID_VERSION()
563
- t.equal(error.name, 'FastifyError')
564
- t.equal(error.code, 'FST_ERR_HTTP2_INVALID_VERSION')
565
- t.equal(error.message, 'HTTP2 is available only from node >= 8.8.1')
566
- t.equal(error.statusCode, 500)
567
- t.ok(error instanceof Error)
563
+ t.assert.strictEqual(error.name, 'FastifyError')
564
+ t.assert.strictEqual(error.code, 'FST_ERR_HTTP2_INVALID_VERSION')
565
+ t.assert.strictEqual(error.message, 'HTTP2 is available only from node >= 8.8.1')
566
+ t.assert.strictEqual(error.statusCode, 500)
567
+ t.assert.ok(error instanceof Error)
568
568
  })
569
569
 
570
570
  test('FST_ERR_INIT_OPTS_INVALID', t => {
571
571
  t.plan(5)
572
572
  const error = new errors.FST_ERR_INIT_OPTS_INVALID()
573
- t.equal(error.name, 'FastifyError')
574
- t.equal(error.code, 'FST_ERR_INIT_OPTS_INVALID')
575
- t.equal(error.message, "Invalid initialization options: '%s'")
576
- t.equal(error.statusCode, 500)
577
- t.ok(error instanceof Error)
573
+ t.assert.strictEqual(error.name, 'FastifyError')
574
+ t.assert.strictEqual(error.code, 'FST_ERR_INIT_OPTS_INVALID')
575
+ t.assert.strictEqual(error.message, "Invalid initialization options: '%s'")
576
+ t.assert.strictEqual(error.statusCode, 500)
577
+ t.assert.ok(error instanceof Error)
578
578
  })
579
579
 
580
580
  test('FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE', t => {
581
581
  t.plan(5)
582
582
  const error = new errors.FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE()
583
- t.equal(error.name, 'FastifyError')
584
- t.equal(error.code, 'FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE')
585
- t.equal(error.message, "Cannot set forceCloseConnections to 'idle' as your HTTP server does not support closeIdleConnections method")
586
- t.equal(error.statusCode, 500)
587
- t.ok(error instanceof Error)
583
+ t.assert.strictEqual(error.name, 'FastifyError')
584
+ t.assert.strictEqual(error.code, 'FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE')
585
+ t.assert.strictEqual(error.message, "Cannot set forceCloseConnections to 'idle' as your HTTP server does not support closeIdleConnections method")
586
+ t.assert.strictEqual(error.statusCode, 500)
587
+ t.assert.ok(error instanceof Error)
588
588
  })
589
589
 
590
590
  test('FST_ERR_DUPLICATED_ROUTE', t => {
591
591
  t.plan(5)
592
592
  const error = new errors.FST_ERR_DUPLICATED_ROUTE()
593
- t.equal(error.name, 'FastifyError')
594
- t.equal(error.code, 'FST_ERR_DUPLICATED_ROUTE')
595
- t.equal(error.message, "Method '%s' already declared for route '%s'")
596
- t.equal(error.statusCode, 500)
597
- t.ok(error instanceof Error)
593
+ t.assert.strictEqual(error.name, 'FastifyError')
594
+ t.assert.strictEqual(error.code, 'FST_ERR_DUPLICATED_ROUTE')
595
+ t.assert.strictEqual(error.message, "Method '%s' already declared for route '%s'")
596
+ t.assert.strictEqual(error.statusCode, 500)
597
+ t.assert.ok(error instanceof Error)
598
598
  })
599
599
 
600
600
  test('FST_ERR_BAD_URL', t => {
601
601
  t.plan(5)
602
602
  const error = new errors.FST_ERR_BAD_URL()
603
- t.equal(error.name, 'FastifyError')
604
- t.equal(error.code, 'FST_ERR_BAD_URL')
605
- t.equal(error.message, "'%s' is not a valid url component")
606
- t.equal(error.statusCode, 400)
607
- t.ok(error instanceof Error)
603
+ t.assert.strictEqual(error.name, 'FastifyError')
604
+ t.assert.strictEqual(error.code, 'FST_ERR_BAD_URL')
605
+ t.assert.strictEqual(error.message, "'%s' is not a valid url component")
606
+ t.assert.strictEqual(error.statusCode, 400)
607
+ t.assert.ok(error instanceof Error)
608
608
  })
609
609
 
610
610
  test('FST_ERR_ASYNC_CONSTRAINT', t => {
611
611
  t.plan(5)
612
612
  const error = new errors.FST_ERR_ASYNC_CONSTRAINT()
613
- t.equal(error.name, 'FastifyError')
614
- t.equal(error.code, 'FST_ERR_ASYNC_CONSTRAINT')
615
- t.equal(error.message, 'Unexpected error from async constraint')
616
- t.equal(error.statusCode, 500)
617
- t.ok(error instanceof Error)
613
+ t.assert.strictEqual(error.name, 'FastifyError')
614
+ t.assert.strictEqual(error.code, 'FST_ERR_ASYNC_CONSTRAINT')
615
+ t.assert.strictEqual(error.message, 'Unexpected error from async constraint')
616
+ t.assert.strictEqual(error.statusCode, 500)
617
+ t.assert.ok(error instanceof Error)
618
618
  })
619
619
 
620
620
  test('FST_ERR_INVALID_URL', t => {
621
621
  t.plan(5)
622
622
  const error = new errors.FST_ERR_INVALID_URL()
623
- t.equal(error.name, 'FastifyError')
624
- t.equal(error.code, 'FST_ERR_INVALID_URL')
625
- t.equal(error.message, "URL must be a string. Received '%s'")
626
- t.equal(error.statusCode, 400)
627
- t.ok(error instanceof TypeError)
623
+ t.assert.strictEqual(error.name, 'FastifyError')
624
+ t.assert.strictEqual(error.code, 'FST_ERR_INVALID_URL')
625
+ t.assert.strictEqual(error.message, "URL must be a string. Received '%s'")
626
+ t.assert.strictEqual(error.statusCode, 400)
627
+ t.assert.ok(error instanceof TypeError)
628
628
  })
629
629
 
630
630
  test('FST_ERR_ROUTE_OPTIONS_NOT_OBJ', t => {
631
631
  t.plan(5)
632
632
  const error = new errors.FST_ERR_ROUTE_OPTIONS_NOT_OBJ()
633
- t.equal(error.name, 'FastifyError')
634
- t.equal(error.code, 'FST_ERR_ROUTE_OPTIONS_NOT_OBJ')
635
- t.equal(error.message, 'Options for "%s:%s" route must be an object')
636
- t.equal(error.statusCode, 500)
637
- t.ok(error instanceof TypeError)
633
+ t.assert.strictEqual(error.name, 'FastifyError')
634
+ t.assert.strictEqual(error.code, 'FST_ERR_ROUTE_OPTIONS_NOT_OBJ')
635
+ t.assert.strictEqual(error.message, 'Options for "%s:%s" route must be an object')
636
+ t.assert.strictEqual(error.statusCode, 500)
637
+ t.assert.ok(error instanceof TypeError)
638
638
  })
639
639
 
640
640
  test('FST_ERR_ROUTE_DUPLICATED_HANDLER', t => {
641
641
  t.plan(5)
642
642
  const error = new errors.FST_ERR_ROUTE_DUPLICATED_HANDLER()
643
- t.equal(error.name, 'FastifyError')
644
- t.equal(error.code, 'FST_ERR_ROUTE_DUPLICATED_HANDLER')
645
- t.equal(error.message, 'Duplicate handler for "%s:%s" route is not allowed!')
646
- t.equal(error.statusCode, 500)
647
- t.ok(error instanceof Error)
643
+ t.assert.strictEqual(error.name, 'FastifyError')
644
+ t.assert.strictEqual(error.code, 'FST_ERR_ROUTE_DUPLICATED_HANDLER')
645
+ t.assert.strictEqual(error.message, 'Duplicate handler for "%s:%s" route is not allowed!')
646
+ t.assert.strictEqual(error.statusCode, 500)
647
+ t.assert.ok(error instanceof Error)
648
648
  })
649
649
 
650
650
  test('FST_ERR_ROUTE_HANDLER_NOT_FN', t => {
651
651
  t.plan(5)
652
652
  const error = new errors.FST_ERR_ROUTE_HANDLER_NOT_FN()
653
- t.equal(error.name, 'FastifyError')
654
- t.equal(error.code, 'FST_ERR_ROUTE_HANDLER_NOT_FN')
655
- t.equal(error.message, 'Error Handler for %s:%s route, if defined, must be a function')
656
- t.equal(error.statusCode, 500)
657
- t.ok(error instanceof TypeError)
653
+ t.assert.strictEqual(error.name, 'FastifyError')
654
+ t.assert.strictEqual(error.code, 'FST_ERR_ROUTE_HANDLER_NOT_FN')
655
+ t.assert.strictEqual(error.message, 'Error Handler for %s:%s route, if defined, must be a function')
656
+ t.assert.strictEqual(error.statusCode, 500)
657
+ t.assert.ok(error instanceof TypeError)
658
658
  })
659
659
 
660
660
  test('FST_ERR_ROUTE_MISSING_HANDLER', t => {
661
661
  t.plan(5)
662
662
  const error = new errors.FST_ERR_ROUTE_MISSING_HANDLER()
663
- t.equal(error.name, 'FastifyError')
664
- t.equal(error.code, 'FST_ERR_ROUTE_MISSING_HANDLER')
665
- t.equal(error.message, 'Missing handler function for "%s:%s" route.')
666
- t.equal(error.statusCode, 500)
667
- t.ok(error instanceof Error)
663
+ t.assert.strictEqual(error.name, 'FastifyError')
664
+ t.assert.strictEqual(error.code, 'FST_ERR_ROUTE_MISSING_HANDLER')
665
+ t.assert.strictEqual(error.message, 'Missing handler function for "%s:%s" route.')
666
+ t.assert.strictEqual(error.statusCode, 500)
667
+ t.assert.ok(error instanceof Error)
668
668
  })
669
669
 
670
670
  test('FST_ERR_ROUTE_METHOD_INVALID', t => {
671
671
  t.plan(5)
672
672
  const error = new errors.FST_ERR_ROUTE_METHOD_INVALID()
673
- t.equal(error.name, 'FastifyError')
674
- t.equal(error.code, 'FST_ERR_ROUTE_METHOD_INVALID')
675
- t.equal(error.message, 'Provided method is invalid!')
676
- t.equal(error.statusCode, 500)
677
- t.ok(error instanceof TypeError)
673
+ t.assert.strictEqual(error.name, 'FastifyError')
674
+ t.assert.strictEqual(error.code, 'FST_ERR_ROUTE_METHOD_INVALID')
675
+ t.assert.strictEqual(error.message, 'Provided method is invalid!')
676
+ t.assert.strictEqual(error.statusCode, 500)
677
+ t.assert.ok(error instanceof TypeError)
678
678
  })
679
679
 
680
680
  test('FST_ERR_ROUTE_METHOD_NOT_SUPPORTED', t => {
681
681
  t.plan(5)
682
682
  const error = new errors.FST_ERR_ROUTE_METHOD_NOT_SUPPORTED()
683
- t.equal(error.name, 'FastifyError')
684
- t.equal(error.code, 'FST_ERR_ROUTE_METHOD_NOT_SUPPORTED')
685
- t.equal(error.message, '%s method is not supported.')
686
- t.equal(error.statusCode, 500)
687
- t.ok(error instanceof Error)
683
+ t.assert.strictEqual(error.name, 'FastifyError')
684
+ t.assert.strictEqual(error.code, 'FST_ERR_ROUTE_METHOD_NOT_SUPPORTED')
685
+ t.assert.strictEqual(error.message, '%s method is not supported.')
686
+ t.assert.strictEqual(error.statusCode, 500)
687
+ t.assert.ok(error instanceof Error)
688
688
  })
689
689
 
690
690
  test('FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED', t => {
691
691
  t.plan(5)
692
692
  const error = new errors.FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED()
693
- t.equal(error.name, 'FastifyError')
694
- t.equal(error.code, 'FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED')
695
- t.equal(error.message, 'Body validation schema for %s:%s route is not supported!')
696
- t.equal(error.statusCode, 500)
697
- t.ok(error instanceof Error)
693
+ t.assert.strictEqual(error.name, 'FastifyError')
694
+ t.assert.strictEqual(error.code, 'FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED')
695
+ t.assert.strictEqual(error.message, 'Body validation schema for %s:%s route is not supported!')
696
+ t.assert.strictEqual(error.statusCode, 500)
697
+ t.assert.ok(error instanceof Error)
698
698
  })
699
699
 
700
700
  test('FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT', t => {
701
701
  t.plan(5)
702
702
  const error = new errors.FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT()
703
- t.equal(error.name, 'FastifyError')
704
- t.equal(error.code, 'FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT')
705
- t.equal(error.message, "'bodyLimit' option must be an integer > 0. Got '%s'")
706
- t.equal(error.statusCode, 500)
707
- t.ok(error instanceof TypeError)
703
+ t.assert.strictEqual(error.name, 'FastifyError')
704
+ t.assert.strictEqual(error.code, 'FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT')
705
+ t.assert.strictEqual(error.message, "'bodyLimit' option must be an integer > 0. Got '%s'")
706
+ t.assert.strictEqual(error.statusCode, 500)
707
+ t.assert.ok(error instanceof TypeError)
708
708
  })
709
709
 
710
710
  test('FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT', t => {
711
711
  t.plan(5)
712
712
  const error = new errors.FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT()
713
- t.equal(error.name, 'FastifyError')
714
- t.equal(error.code, 'FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT')
715
- t.equal(error.message, "'bodyLimit' option must be an integer > 0. Got '%s'")
716
- t.equal(error.statusCode, 500)
717
- t.ok(error instanceof TypeError)
713
+ t.assert.strictEqual(error.name, 'FastifyError')
714
+ t.assert.strictEqual(error.code, 'FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT')
715
+ t.assert.strictEqual(error.message, "'bodyLimit' option must be an integer > 0. Got '%s'")
716
+ t.assert.strictEqual(error.statusCode, 500)
717
+ t.assert.ok(error instanceof TypeError)
718
718
  })
719
719
 
720
720
  test('FST_ERR_ROUTE_REWRITE_NOT_STR', t => {
721
721
  t.plan(5)
722
722
  const error = new errors.FST_ERR_ROUTE_REWRITE_NOT_STR()
723
- t.equal(error.name, 'FastifyError')
724
- t.equal(error.code, 'FST_ERR_ROUTE_REWRITE_NOT_STR')
725
- t.equal(error.message, 'Rewrite url for "%s" needs to be of type "string" but received "%s"')
726
- t.equal(error.statusCode, 500)
727
- t.ok(error instanceof TypeError)
723
+ t.assert.strictEqual(error.name, 'FastifyError')
724
+ t.assert.strictEqual(error.code, 'FST_ERR_ROUTE_REWRITE_NOT_STR')
725
+ t.assert.strictEqual(error.message, 'Rewrite url for "%s" needs to be of type "string" but received "%s"')
726
+ t.assert.strictEqual(error.statusCode, 500)
727
+ t.assert.ok(error instanceof TypeError)
728
728
  })
729
729
 
730
730
  test('FST_ERR_REOPENED_CLOSE_SERVER', t => {
731
731
  t.plan(5)
732
732
  const error = new errors.FST_ERR_REOPENED_CLOSE_SERVER()
733
- t.equal(error.name, 'FastifyError')
734
- t.equal(error.code, 'FST_ERR_REOPENED_CLOSE_SERVER')
735
- t.equal(error.message, 'Fastify has already been closed and cannot be reopened')
736
- t.equal(error.statusCode, 500)
737
- t.ok(error instanceof Error)
733
+ t.assert.strictEqual(error.name, 'FastifyError')
734
+ t.assert.strictEqual(error.code, 'FST_ERR_REOPENED_CLOSE_SERVER')
735
+ t.assert.strictEqual(error.message, 'Fastify has already been closed and cannot be reopened')
736
+ t.assert.strictEqual(error.statusCode, 500)
737
+ t.assert.ok(error instanceof Error)
738
738
  })
739
739
 
740
740
  test('FST_ERR_REOPENED_SERVER', t => {
741
741
  t.plan(5)
742
742
  const error = new errors.FST_ERR_REOPENED_SERVER()
743
- t.equal(error.name, 'FastifyError')
744
- t.equal(error.code, 'FST_ERR_REOPENED_SERVER')
745
- t.equal(error.message, 'Fastify is already listening')
746
- t.equal(error.statusCode, 500)
747
- t.ok(error instanceof Error)
743
+ t.assert.strictEqual(error.name, 'FastifyError')
744
+ t.assert.strictEqual(error.code, 'FST_ERR_REOPENED_SERVER')
745
+ t.assert.strictEqual(error.message, 'Fastify is already listening')
746
+ t.assert.strictEqual(error.statusCode, 500)
747
+ t.assert.ok(error instanceof Error)
748
748
  })
749
749
 
750
750
  test('FST_ERR_INSTANCE_ALREADY_LISTENING', t => {
751
751
  t.plan(5)
752
752
  const error = new errors.FST_ERR_INSTANCE_ALREADY_LISTENING()
753
- t.equal(error.name, 'FastifyError')
754
- t.equal(error.code, 'FST_ERR_INSTANCE_ALREADY_LISTENING')
755
- t.equal(error.message, 'Fastify instance is already listening. %s')
756
- t.equal(error.statusCode, 500)
757
- t.ok(error instanceof Error)
753
+ t.assert.strictEqual(error.name, 'FastifyError')
754
+ t.assert.strictEqual(error.code, 'FST_ERR_INSTANCE_ALREADY_LISTENING')
755
+ t.assert.strictEqual(error.message, 'Fastify instance is already listening. %s')
756
+ t.assert.strictEqual(error.statusCode, 500)
757
+ t.assert.ok(error instanceof Error)
758
758
  })
759
759
 
760
760
  test('FST_ERR_PLUGIN_VERSION_MISMATCH', t => {
761
761
  t.plan(5)
762
762
  const error = new errors.FST_ERR_PLUGIN_VERSION_MISMATCH()
763
- t.equal(error.name, 'FastifyError')
764
- t.equal(error.code, 'FST_ERR_PLUGIN_VERSION_MISMATCH')
765
- t.equal(error.message, "fastify-plugin: %s - expected '%s' fastify version, '%s' is installed")
766
- t.equal(error.statusCode, 500)
767
- t.ok(error instanceof Error)
763
+ t.assert.strictEqual(error.name, 'FastifyError')
764
+ t.assert.strictEqual(error.code, 'FST_ERR_PLUGIN_VERSION_MISMATCH')
765
+ t.assert.strictEqual(error.message, "fastify-plugin: %s - expected '%s' fastify version, '%s' is installed")
766
+ t.assert.strictEqual(error.statusCode, 500)
767
+ t.assert.ok(error instanceof Error)
768
768
  })
769
769
 
770
770
  test('FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE', t => {
771
771
  t.plan(5)
772
772
  const error = new errors.FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE()
773
- t.equal(error.name, 'FastifyError')
774
- t.equal(error.code, 'FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE')
775
- t.equal(error.message, "The decorator '%s'%s is not present in %s")
776
- t.equal(error.statusCode, 500)
777
- t.ok(error instanceof Error)
773
+ t.assert.strictEqual(error.name, 'FastifyError')
774
+ t.assert.strictEqual(error.code, 'FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE')
775
+ t.assert.strictEqual(error.message, "The decorator '%s'%s is not present in %s")
776
+ t.assert.strictEqual(error.statusCode, 500)
777
+ t.assert.ok(error instanceof Error)
778
778
  })
779
779
 
780
780
  test('FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER', t => {
781
781
  t.plan(5)
782
782
  const error = new errors.FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER('easter-egg')
783
- t.equal(error.name, 'FastifyError')
784
- t.equal(error.code, 'FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER')
785
- t.equal(error.message, 'The easter-egg plugin being registered mixes async and callback styles. Async plugin should not mix async and callback style.')
786
- t.equal(error.statusCode, 500)
787
- t.ok(error instanceof TypeError)
783
+ t.assert.strictEqual(error.name, 'FastifyError')
784
+ t.assert.strictEqual(error.code, 'FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER')
785
+ t.assert.strictEqual(error.message, 'The easter-egg plugin being registered mixes async and callback styles. Async plugin should not mix async and callback style.')
786
+ t.assert.strictEqual(error.statusCode, 500)
787
+ t.assert.ok(error instanceof TypeError)
788
788
  })
789
789
 
790
790
  test('FST_ERR_PLUGIN_CALLBACK_NOT_FN', t => {
791
791
  t.plan(5)
792
792
  const error = new errors.FST_ERR_PLUGIN_CALLBACK_NOT_FN()
793
- t.equal(error.name, 'FastifyError')
794
- t.equal(error.code, 'FST_ERR_PLUGIN_CALLBACK_NOT_FN')
795
- t.equal(error.message, 'fastify-plugin: %s')
796
- t.equal(error.statusCode, 500)
797
- t.ok(error instanceof TypeError)
793
+ t.assert.strictEqual(error.name, 'FastifyError')
794
+ t.assert.strictEqual(error.code, 'FST_ERR_PLUGIN_CALLBACK_NOT_FN')
795
+ t.assert.strictEqual(error.message, 'fastify-plugin: %s')
796
+ t.assert.strictEqual(error.statusCode, 500)
797
+ t.assert.ok(error instanceof TypeError)
798
798
  })
799
799
 
800
800
  test('FST_ERR_PLUGIN_NOT_VALID', t => {
801
801
  t.plan(5)
802
802
  const error = new errors.FST_ERR_PLUGIN_NOT_VALID()
803
- t.equal(error.name, 'FastifyError')
804
- t.equal(error.code, 'FST_ERR_PLUGIN_NOT_VALID')
805
- t.equal(error.message, 'fastify-plugin: %s')
806
- t.equal(error.statusCode, 500)
807
- t.ok(error instanceof Error)
803
+ t.assert.strictEqual(error.name, 'FastifyError')
804
+ t.assert.strictEqual(error.code, 'FST_ERR_PLUGIN_NOT_VALID')
805
+ t.assert.strictEqual(error.message, 'fastify-plugin: %s')
806
+ t.assert.strictEqual(error.statusCode, 500)
807
+ t.assert.ok(error instanceof Error)
808
808
  })
809
809
 
810
810
  test('FST_ERR_ROOT_PLG_BOOTED', t => {
811
811
  t.plan(5)
812
812
  const error = new errors.FST_ERR_ROOT_PLG_BOOTED()
813
- t.equal(error.name, 'FastifyError')
814
- t.equal(error.code, 'FST_ERR_ROOT_PLG_BOOTED')
815
- t.equal(error.message, 'fastify-plugin: %s')
816
- t.equal(error.statusCode, 500)
817
- t.ok(error instanceof Error)
813
+ t.assert.strictEqual(error.name, 'FastifyError')
814
+ t.assert.strictEqual(error.code, 'FST_ERR_ROOT_PLG_BOOTED')
815
+ t.assert.strictEqual(error.message, 'fastify-plugin: %s')
816
+ t.assert.strictEqual(error.statusCode, 500)
817
+ t.assert.ok(error instanceof Error)
818
818
  })
819
819
 
820
820
  test('FST_ERR_PARENT_PLUGIN_BOOTED', t => {
821
821
  t.plan(5)
822
822
  const error = new errors.FST_ERR_PARENT_PLUGIN_BOOTED()
823
- t.equal(error.name, 'FastifyError')
824
- t.equal(error.code, 'FST_ERR_PARENT_PLUGIN_BOOTED')
825
- t.equal(error.message, 'fastify-plugin: %s')
826
- t.equal(error.statusCode, 500)
827
- t.ok(error instanceof Error)
823
+ t.assert.strictEqual(error.name, 'FastifyError')
824
+ t.assert.strictEqual(error.code, 'FST_ERR_PARENT_PLUGIN_BOOTED')
825
+ t.assert.strictEqual(error.message, 'fastify-plugin: %s')
826
+ t.assert.strictEqual(error.statusCode, 500)
827
+ t.assert.ok(error instanceof Error)
828
828
  })
829
829
 
830
830
  test('FST_ERR_PLUGIN_TIMEOUT', t => {
831
831
  t.plan(5)
832
832
  const error = new errors.FST_ERR_PLUGIN_TIMEOUT()
833
- t.equal(error.name, 'FastifyError')
834
- t.equal(error.code, 'FST_ERR_PLUGIN_TIMEOUT')
835
- t.equal(error.message, 'fastify-plugin: %s')
836
- t.equal(error.statusCode, 500)
837
- t.ok(error instanceof Error)
833
+ t.assert.strictEqual(error.name, 'FastifyError')
834
+ t.assert.strictEqual(error.code, 'FST_ERR_PLUGIN_TIMEOUT')
835
+ t.assert.strictEqual(error.message, 'fastify-plugin: %s')
836
+ t.assert.strictEqual(error.statusCode, 500)
837
+ t.assert.ok(error instanceof Error)
838
838
  })
839
839
 
840
840
  test('FST_ERR_VALIDATION', t => {
841
841
  t.plan(5)
842
842
  const error = new errors.FST_ERR_VALIDATION()
843
- t.equal(error.name, 'FastifyError')
844
- t.equal(error.code, 'FST_ERR_VALIDATION')
845
- t.equal(error.message, '%s')
846
- t.equal(error.statusCode, 400)
847
- t.ok(error instanceof Error)
843
+ t.assert.strictEqual(error.name, 'FastifyError')
844
+ t.assert.strictEqual(error.code, 'FST_ERR_VALIDATION')
845
+ t.assert.strictEqual(error.message, '%s')
846
+ t.assert.strictEqual(error.statusCode, 400)
847
+ t.assert.ok(error instanceof Error)
848
848
  })
849
849
 
850
850
  test('FST_ERR_LISTEN_OPTIONS_INVALID', t => {
851
851
  t.plan(5)
852
852
  const error = new errors.FST_ERR_LISTEN_OPTIONS_INVALID()
853
- t.equal(error.name, 'FastifyError')
854
- t.equal(error.code, 'FST_ERR_LISTEN_OPTIONS_INVALID')
855
- t.equal(error.message, "Invalid listen options: '%s'")
856
- t.equal(error.statusCode, 500)
857
- t.ok(error instanceof TypeError)
853
+ t.assert.strictEqual(error.name, 'FastifyError')
854
+ t.assert.strictEqual(error.code, 'FST_ERR_LISTEN_OPTIONS_INVALID')
855
+ t.assert.strictEqual(error.message, "Invalid listen options: '%s'")
856
+ t.assert.strictEqual(error.statusCode, 500)
857
+ t.assert.ok(error instanceof TypeError)
858
858
  })
859
859
 
860
860
  test('FST_ERR_ERROR_HANDLER_NOT_FN', t => {
861
861
  t.plan(5)
862
862
  const error = new errors.FST_ERR_ERROR_HANDLER_NOT_FN()
863
- t.equal(error.name, 'FastifyError')
864
- t.equal(error.code, 'FST_ERR_ERROR_HANDLER_NOT_FN')
865
- t.equal(error.message, 'Error Handler must be a function')
866
- t.equal(error.statusCode, 500)
867
- t.ok(error instanceof TypeError)
863
+ t.assert.strictEqual(error.name, 'FastifyError')
864
+ t.assert.strictEqual(error.code, 'FST_ERR_ERROR_HANDLER_NOT_FN')
865
+ t.assert.strictEqual(error.message, 'Error Handler must be a function')
866
+ t.assert.strictEqual(error.statusCode, 500)
867
+ t.assert.ok(error instanceof TypeError)
868
868
  })
869
869
 
870
870
  test('Ensure that all errors are in Errors.md TOC', t => {
@@ -874,7 +874,7 @@ test('Ensure that all errors are in Errors.md TOC', t => {
874
874
  const exportedKeys = Object.keys(errors)
875
875
  for (const key of exportedKeys) {
876
876
  if (errors[key].name === 'FastifyError') {
877
- t.ok(errorsMd.includes(` - [${key.toUpperCase()}](#${key.toLowerCase()})`), key)
877
+ t.assert.ok(errorsMd.includes(` - [${key.toUpperCase()}](#${key.toLowerCase()})`), key)
878
878
  }
879
879
  }
880
880
  })
@@ -888,7 +888,7 @@ test('Ensure that non-existing errors are not in Errors.md TOC', t => {
888
888
  const exportedKeys = Object.keys(errors)
889
889
 
890
890
  for (const match of matches) {
891
- t.ok(exportedKeys.indexOf(match[1]) !== -1, match[1])
891
+ t.assert.ok(exportedKeys.indexOf(match[1]) !== -1, match[1])
892
892
  }
893
893
  })
894
894
 
@@ -899,7 +899,7 @@ test('Ensure that all errors are in Errors.md documented', t => {
899
899
  const exportedKeys = Object.keys(errors)
900
900
  for (const key of exportedKeys) {
901
901
  if (errors[key].name === 'FastifyError') {
902
- t.ok(errorsMd.includes(`<a id="${key.toLowerCase()}">${key.toUpperCase()}</a>`), key)
902
+ t.assert.ok(errorsMd.includes(`<a id="${key.toLowerCase()}">${key.toUpperCase()}</a>`), key)
903
903
  }
904
904
  }
905
905
  })
@@ -913,6 +913,6 @@ test('Ensure that non-existing errors are not in Errors.md documented', t => {
913
913
  const exportedKeys = Object.keys(errors)
914
914
 
915
915
  for (const match of matches) {
916
- t.ok(exportedKeys.indexOf(match[1]) !== -1, match[1])
916
+ t.assert.ok(exportedKeys.indexOf(match[1]) !== -1, match[1])
917
917
  }
918
918
  })