diff --git a/src/index.ts b/src/index.ts index 1a8d361..e190878 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,10 @@ export * from './chai' -import test from './test' -export {test} +import test, {Test, TestBase} from './test' + +export { + Test, + TestBase, + test, +} export default test diff --git a/src/test.ts b/src/test.ts index 2be6845..64685c7 100644 --- a/src/test.ts +++ b/src/test.ts @@ -22,15 +22,15 @@ export type DescribeCallback = TestCallback { - (expectation: string, cb: ItCallback): mocha.ITest - only(expectation: string, cb: ItCallback): mocha.ITest - skip(expectation: string, cb: ItCallback): void + (expectation: string, cb?: ItCallback): mocha.ITest + only(expectation: string, cb?: ItCallback): mocha.ITest + skip(expectation: string, cb?: ItCallback): void } export interface Describe { (expectation: string, cb: DescribeCallback): mocha.ISuite only(expectation: string, cb: DescribeCallback): mocha.ISuite - skip(expectation: string, cb: (this: mocha.ISuiteCallbackContext) => void): void + skip(expectation: string, cb?: (this: mocha.ISuiteCallbackContext) => void): void } export interface TestBase { @@ -119,9 +119,14 @@ const test = (previous?: Test): TestB return context } const _catch = async (err: Error, context?: object) => { + let handled = false for (let f of filters) { - if (f.catch) await f.catch(context, err) + if (f.catch) { + await f.catch(context, err) + handled = true + } } + return handled } const _finally = async (context?: object) => { for (let f of filters) { @@ -142,7 +147,9 @@ const test = (previous?: Test): TestB await after(context) } catch (err) { error = err - await _catch(err) + if (await _catch(err)) { + error = false + } } finally { await _finally() }