import { config, DOMWrapper } from '@vue/test-utils'; import { ComponentPublicInstance } from 'vue'; declare module '@vue/test-utils' { interface VueWrapper { findByTestId(selector: string): DOMWrapper; findComponentByTestId(selector: string): VueWrapper; } interface DOMWrapper { findByTestId(selector: string): DOMWrapper; findComponentByTestId(selector: string): VueWrapper; } } const findByTestIdPlugin = (wrapper: any) => { function findByTestId(selector: string): DOMWrapper { const testId = `[data-testid="${selector}"]`; return wrapper.find(testId); } function findComponentByTestId(selector: string) { const testId = `[data-testid="${selector}"]`; return wrapper.findComponent(testId); } return { findByTestId, findComponentByTestId }; }; config.plugins.VueWrapper.install(findByTestIdPlugin); config.plugins.DOMWrapper.install(findByTestIdPlugin);