Suppose I need to unit test this utility function. I am utilizing Vue 3, however, this code resides in a "regular" JavaScript file rather than an SFC.
How can I go about doing that?
function getDynamicComponent() {
if (...) {
return defineAsyncComponent(() => import('../path/to/component-A.vue'))
} else {
return defineAsyncComponent(() => import('../path/to/component-B.vue'))
}
}
In scenarios like this, my approach is to mock the implementation of functions and verify .toHaveBeenCalledWith(...)
. But since I cannot do that with import
, right?
P.S. Any insights into Jest or Vitest syntax would be greatly appreciated