nuxt / test-utils

🧪 Test utilities for Nuxt
http://nuxt.com/docs/getting-started/testing
MIT License
313 stars 81 forks source link

Error: This module cannot be imported in the Vue part of your app #747

Open AlbertBrand opened 8 months ago

AlbertBrand commented 8 months ago

Environment

Reproduction

https://stackblitz.com/edit/github-3etpwp?file=package.json

Describe the bug

If you have test files in your pages folder importing @nuxt/test-utils/runtime, the following error pops up when starting the project

ERROR  This module cannot be imported in the Vue part of your app. [importing @nuxt/test-utils/runtime from pages/<testname>.ts]

The error does not seem to have effect on the app startup itself (it's probably more a warning).

The error goes away when moving the test out of the pages folder.

Additional context

No response

Logs

No response

wattanx commented 8 months ago

It seems that .nuxtignore can be used to avoid this. https://nuxt.com/docs/guide/directory-structure/nuxtignore

// .nuxtignore
pages/*.nuxt.spec.ts