First of all I have to say that the nuxt documentation for unit testing a nuxt module is sooo bad, me and all my colleagues are not able to create even a tiny unit test. So what I am trying to do is to unit test a component of my nuxt module. Basically I just want to check that the produced html of that component matches a snapshot. So I created a file MyButton.nuxt.spec.ts and inserted this code:
describe('MyButton', async () => {
await setup({
rootDir: fileURLToPath(new URL('../fixtures/basic', import.meta.url)),
})
it('renders correctly', async () => {
const html = await mountSuspended(MyButton)
expect(html).toContain('<button>')
})
})
In fixtures/basic there is a nuxt.config.ts file that has just this little config:
import MyModule from '../../../src/module'
export default defineNuxtConfig({
modules: [
MyModule,
],
})
But when I run npm run test I get this error Error: [unimport] failed to find "LazyMyButton" imported from "#components". What am I doing wrong? You can click here to see the full repository.