schlechtenburg/test/with-setup.ts

18 lines
396 B
TypeScript
Raw Normal View History

2024-10-08 07:15:26 +00:00
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;
}