13 lines
365 B
TypeScript
Executable File
13 lines
365 B
TypeScript
Executable File
import { Container, type Constructable } from '@n8n/di';
|
|
import { mock } from 'jest-mock-extended';
|
|
import type { DeepPartial } from 'ts-essentials';
|
|
|
|
export const mockInstance = <T>(
|
|
serviceClass: Constructable<T>,
|
|
data: DeepPartial<T> | undefined = undefined,
|
|
) => {
|
|
const instance = mock<T>(data);
|
|
Container.set(serviceClass, instance);
|
|
return instance;
|
|
};
|