Skip to content

"Cannot find module" when importing .vue files #518

@dschmidt

Description

@dschmidt

Hello,

I seem to be missing something super obvious, but I can't make @vue/vue3-jest work with TypeScript (while @vue/vue2-jest was working just fine).
Whenever I try to import a component from a .vue file, I get errors like

src/main.ts:3:17 - error TS2307: Cannot find module './App.vue' or its corresponding type declarations.

It doesn't matter if it's in the spec file directly or indirectly in a .ts file imported from a spec file.

I've created a minimal example here: https://github.com/dschmidt/vue3-compat
You can see the error with: pnpm i && pnpm jest:clean

As I'm currently trying to port an application to Vue 3, I'm collecting a few issues there (and hence the name) but it should be basically as minimal as can be. So far I could not tell that the compatConfig has any influence on this.

Also interesting: it does not seem to make a difference whether the transform is active in the jest config or not. The error does not change. 😕

.. and just for the sake of completeness: vite dev server, vite prod builds and vue-tsc of course don't complain about anything - the issue just occurs when trying to run jest.

Am I messing this up or is something really broken?
Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions