Skip to content

Commit d6c6a7a

Browse files
committed
test: update tests to use Error.isError instead of util.isError on newer node versions
1 parent 138fb1a commit d6c6a7a

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

test/test.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@ var util = require('util')
66

77
var createError = require('..')
88

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+
921
describe('createError(status)', function () {
1022
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)))
1224
})
1325

1426
describe('Extending Existing Errors with HTTP Properties', function () {
@@ -126,7 +138,7 @@ describe('createError(status, message)', function () {
126138
})
127139

128140
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))
130142
})
131143

132144
it('should have "message" property with message', function () {
@@ -419,11 +431,17 @@ describe('HTTP Errors', function () {
419431
assert((new createError['500']()) instanceof createError.HttpError)
420432
})
421433

422-
it('should support util.isError()', function () {
434+
itUtilIsError('should support util.isError()', function () {
423435
/* eslint-disable node/no-deprecated-api */
424436
assert(util.isError(createError(404)))
425437
assert(util.isError(new createError['404']()))
426438
assert(util.isError(new createError['500']()))
427439
/* eslint-enable node/no-deprecated-api */
428440
})
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+
})
429447
})

0 commit comments

Comments
 (0)