@@ -6,9 +6,21 @@ var util = require('util')
6
6
7
7
var createError = require ( '..' )
8
8
9
+ // eslint-disable-next-line node/no-deprecated-api
10
+ var isError = typeof Error . isError === 'function' ? Error . isError : util . isError
11
+
12
+ var itErrorIsError = typeof Error . isError === 'function'
13
+ ? it
14
+ : it . skip
15
+
16
+ // eslint-disable-next-line node/no-deprecated-api
17
+ var itUtilIsError = typeof util . isError === 'function'
18
+ ? it
19
+ : it . skip
20
+
9
21
describe ( 'createError(status)' , function ( ) {
10
22
it ( 'should create error object' , function ( ) {
11
- assert . ok ( util . isError ( createError ( 500 ) ) ) // eslint-disable-line node/no-deprecated-api
23
+ assert . ok ( isError ( createError ( 500 ) ) )
12
24
} )
13
25
14
26
describe ( 'Extending Existing Errors with HTTP Properties' , function ( ) {
@@ -126,7 +138,7 @@ describe('createError(status, message)', function () {
126
138
} )
127
139
128
140
it ( 'should create error object' , function ( ) {
129
- assert . ok ( util . isError ( this . error ) ) // eslint-disable-line node/no-deprecated-api
141
+ assert . ok ( isError ( this . error ) )
130
142
} )
131
143
132
144
it ( 'should have "message" property with message' , function ( ) {
@@ -419,11 +431,17 @@ describe('HTTP Errors', function () {
419
431
assert ( ( new createError [ '500' ] ( ) ) instanceof createError . HttpError )
420
432
} )
421
433
422
- it ( 'should support util.isError()' , function ( ) {
434
+ itUtilIsError ( 'should support util.isError()' , function ( ) {
423
435
/* eslint-disable node/no-deprecated-api */
424
436
assert ( util . isError ( createError ( 404 ) ) )
425
437
assert ( util . isError ( new createError [ '404' ] ( ) ) )
426
438
assert ( util . isError ( new createError [ '500' ] ( ) ) )
427
439
/* eslint-enable node/no-deprecated-api */
428
440
} )
441
+
442
+ itErrorIsError ( 'should support Error.isError()' , function ( ) {
443
+ assert ( Error . isError ( createError ( 404 ) ) )
444
+ assert ( Error . isError ( new createError [ '404' ] ( ) ) )
445
+ assert ( Error . isError ( new createError [ '500' ] ( ) ) )
446
+ } )
429
447
} )
0 commit comments