schlechtenburg/test/with-setup.ts
2024-10-08 09:15:26 +02:00

18 lines
396 B
TypeScript

import { mount } from '@vue/test-utils';
import { defineComponent } from 'vue'
export function withSetup<T>(composable: () => T): T {
let result: T;
mount(defineComponent({
setup() {
result = composable();
// suppress missing template warning
return () => {}
}
}));
// return the result and the app instance
// for testing provide/unmount
return result;
}