diff --git a/types/tape/index.d.ts b/types/tape/index.d.ts index 581a669606..936f2ac491 100644 --- a/types/tape/index.d.ts +++ b/types/tape/index.d.ts @@ -193,13 +193,13 @@ declare namespace tape { * expected, if present, must be a RegExp or Function, which is used to test the exception object. */ throws(fn: () => void, msg?: string): void; - throws(fn: () => void, exceptionExpected: RegExp | (() => void), msg?: string): void; + throws(fn: () => void, exceptionExpected: RegExp | Function, msg?: string): void; /** * Assert that the function call fn() does not throw an exception. */ doesNotThrow(fn: () => void, msg?: string): void; - doesNotThrow(fn: () => void, exceptionExpected: RegExp | (() => void), msg?: string): void; + doesNotThrow(fn: () => void, exceptionExpected: RegExp | Function, msg?: string): void; /** * Print a message without breaking the tap output. diff --git a/types/tape/tape-tests.ts b/types/tape/tape-tests.ts index 6f5ad605e5..0c67629f58 100644 --- a/types/tape/tape-tests.ts +++ b/types/tape/tape-tests.ts @@ -28,6 +28,12 @@ rs = tape.createStream(sopts); var htest: typeof tape; htest = tape.createHarness(); +class CustomException extends Error { + constructor(message?: string) { + super(message); + } +} + tape(name, (test: tape.Test) => { @@ -146,11 +152,15 @@ tape(name, (test: tape.Test) => { test.throws(fn, msg); test.throws(fn, exceptionExpected); test.throws(fn, exceptionExpected, msg); + test.throws(fn, CustomException); + test.throws(fn, CustomException, msg); test.doesNotThrow(fn); test.doesNotThrow(fn, msg); test.doesNotThrow(fn, exceptionExpected); test.doesNotThrow(fn, exceptionExpected, msg); + test.doesNotThrow(fn, CustomException); + test.doesNotThrow(fn, CustomException, msg); test.test(name, (st) => { t = st;