18 lines
396 B
TypeScript
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;
|
||
|
}
|