mirror of
https://github.com/n8n-io/n8n.git
synced 2026-06-02 09:47:00 +02:00
13 lines
365 B
TypeScript
13 lines
365 B
TypeScript
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;
|
|
};
|