mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Reduce boilterplate code in between tests also cleaned up some imports, and fixed the tests in node.js 20
13 lines
341 B
TypeScript
13 lines
341 B
TypeScript
import { Container } from 'typedi';
|
|
import { mock } from 'jest-mock-extended';
|
|
import type { DeepPartial } from 'ts-essentials';
|
|
|
|
export const mockInstance = <T>(
|
|
ctor: new (...args: unknown[]) => T,
|
|
data: DeepPartial<T> | undefined = undefined,
|
|
) => {
|
|
const instance = mock<T>(data);
|
|
Container.set(ctor, instance);
|
|
return instance;
|
|
};
|