From 29ee91f389690bb1ed7897e54d75bd3a0231a5e3 Mon Sep 17 00:00:00 2001 From: Ilia Marchenko Date: Fri, 28 Jun 2024 13:59:06 +0300 Subject: [PATCH] WAT-3484 --- core/async-assert/src/index.ts | 3 +++ core/types/src/async-assert/index.ts | 6 ++++++ 2 files changed, 9 insertions(+) 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[]; }