n8n/packages/@n8n/nodes-langchain/test/setup.ts

33 lines
738 B
TypeScript

/**
* Global test setup file.
*
* Provides default mocks for DI infrastructure so test files that call
* `Container.get(AiConfig)` at module level don't need to set up their own
* DI mocks unless they need custom behaviour.
*/
vi.mock('@n8n/di', () => ({
Container: {
get: vi.fn().mockImplementation(() => ({
openAiDefaultHeaders: {},
})),
getOrDefault: vi.fn().mockReturnValue(undefined),
set: vi.fn(),
has: vi.fn().mockReturnValue(false),
},
Service: () => () => {},
}));
vi.mock('@n8n/config', async () => {
const actual = await vi.importActual<typeof import('@n8n/config')>('@n8n/config');
class AiConfig {
openAiDefaultHeaders: Record<string, string> = {};
}
return {
...actual,
AiConfig,
};
});