Testing custom Module.
Hello. I'm developing a Nuxt module, this module have component that is using composable that import/export data from
"#build"
. Component is working in real app environment. But how can I test this type of component?
My test throw this error.
Error: Failed to resolve import "#imports" from "node_modules/@nuxt/test-utils/dist/runtime-utils/index.mjs". Does the file exist?1 Reply
Look like problem is that
mountSuspended
is throw the same error even on very basic empty Vue component.
mount
method from @vue/test-utils
is working for component testing but it can't resolve my composable and throw error.
So the question is the same, how to test this type of components ?
I found out that you can resolve '#build'
imports by adding resolve
option to vitest.config
So with that setup I was able to test components using @vue/test-utils
, but it was needed to remove composable and use direct import of options in components import moduleOptions from '#build/ui.options.mjs';