diff --git a/packages/design-system/src/__tests__/render.ts b/packages/design-system/src/__tests__/render.ts new file mode 100644 index 0000000000..afe27e6855 --- /dev/null +++ b/packages/design-system/src/__tests__/render.ts @@ -0,0 +1,20 @@ +import { render } from '@testing-library/vue'; + +import { N8nPlugin } from 'n8n-design-system/plugin'; + +type Component = Parameters[0]; +type RenderOptions = Parameters[1]; + +export const createComponentRenderer = (component: Component) => (options: RenderOptions) => { + const mergedOptions: RenderOptions = { + ...options, + global: { + ...(options?.global ?? {}), + stubs: { + ...(options?.global?.stubs ?? {}), + }, + plugins: [N8nPlugin, ...(options?.global?.plugins ?? [])], + }, + }; + return render(component, mergedOptions); +}; diff --git a/packages/design-system/src/__tests__/setup.ts b/packages/design-system/src/__tests__/setup.ts index 3ad85f014a..6eb1c426fc 100644 --- a/packages/design-system/src/__tests__/setup.ts +++ b/packages/design-system/src/__tests__/setup.ts @@ -4,3 +4,11 @@ import { config } from '@vue/test-utils'; import { N8nPlugin } from 'n8n-design-system/plugin'; config.global.plugins = [N8nPlugin]; + +window.ResizeObserver = + window.ResizeObserver || + vi.fn().mockImplementation(() => ({ + disconnect: vi.fn(), + observe: vi.fn(), + unobserve: vi.fn(), + }));