Jest実行で”Cannot find module or its corresponding type declarations”のエラー
Jest + Typescript でテスト実行した際に”Cannot find module or its corresponding type declarations”となってファイルの import に失敗する場合があります。
この場合はプロジェクトルートに shims-vue.d.ts の名前で下記ファイルを作成して見てください。
//shims-vue.d.ts
declare module '*.vue' {
import Vue from 'vue'
export default Vue
}
これで再度実行するとエラーが出なくなるかと思います。
これは .vue ファイルを Typescript のファイルとして認識させるために必要らしいです。
参考
GitHub - microsoft/TypeScript-Vue-Starter: A starter template for TypeScript and Vue with a detailed README describing how to use the two together.
A starter template for TypeScript and Vue with a detailed README describing how to use the two together. - microsoft/Typ...

コメント