diff --git a/package.json b/package.json index 8c8b81f77..e2ece33a0 100644 --- a/package.json +++ b/package.json @@ -149,13 +149,6 @@ } }, "preset": "ts-jest", - "globals": { - "ts-jest": { - "tsconfig": { - "target": "es6" - } - } - }, "globalSetup": "./tests/global-setup.ts", "setupFilesAfterEnv": [ "./tests/setup.ts" diff --git a/src/utils/errors.ts b/src/utils/errors.ts index ee1353666..5665ed609 100644 --- a/src/utils/errors.ts +++ b/src/utils/errors.ts @@ -8,6 +8,7 @@ import { HttpError } from 'http-errors'; export class AccessTokenError extends Error { public code: string; + /* istanbul ignore next */ constructor(code: string, message: string) { super(message); @@ -19,6 +20,7 @@ export class AccessTokenError extends Error { // Machine readable code. this.code = code; + Object.setPrototypeOf(this, AccessTokenError.prototype); } } @@ -48,6 +50,7 @@ export class HandlerError extends Error { public status: number | undefined; public code: string | undefined; + /* istanbul ignore next */ constructor(error: Error | AccessTokenError | HttpError) { super(htmlSafe(error.message)); @@ -60,5 +63,6 @@ export class HandlerError extends Error { if ('status' in error) { this.status = error.status; } + Object.setPrototypeOf(this, HandlerError.prototype); } } diff --git a/tests/utils/errors.test.ts b/tests/utils/errors.test.ts new file mode 100644 index 000000000..8bc1392bf --- /dev/null +++ b/tests/utils/errors.test.ts @@ -0,0 +1,8 @@ +import { AccessTokenError, HandlerError } from '../../src/utils/errors'; + +describe('errors', () => { + test('should be instance of themselves', () => { + expect(new AccessTokenError('code', 'message')).toBeInstanceOf(AccessTokenError); + expect(new HandlerError(new Error('message'))).toBeInstanceOf(HandlerError); + }); +});