diff --git a/core/async-assert/src/index.ts b/core/async-assert/src/index.ts index b3d9b186..61f111ab 100644 --- a/core/async-assert/src/index.ts +++ b/core/async-assert/src/index.ts @@ -12,6 +12,9 @@ type WrappedPromisedAssertionApi = PromisedAssert & { export function createAssertion(options: IAssertionOptions = {}) { const isSoft = options.isSoft === true; + for (const plugin of options.plugins || []) { + chai.use(plugin); + } // eslint-disable-next-line sonarjs/cognitive-complexity const proxyGetter = (target, fieldName: string) => { if (fieldName === errorMessagesField) { diff --git a/core/types/src/async-assert/index.ts b/core/types/src/async-assert/index.ts index 983c0863..19bd270a 100644 --- a/core/types/src/async-assert/index.ts +++ b/core/types/src/async-assert/index.ts @@ -1,3 +1,8 @@ +import type { use as chaiUse } from 'chai'; + +type First = T extends [infer A, ...any[]] ? A : never; +type ChaiPlugin = First>; + export interface IAssertionSuccessMeta { isSoft: boolean; successMessage?: string; @@ -15,4 +20,5 @@ export interface IAssertionOptions { isSoft?: boolean; onSuccess?: (IAssertionSuccessMeta) => void | Promise; onError?: (IAssertionErrorMeta) => void | Error | Promise; + plugins?: ChaiPlugin[]; }