nuxt / nuxt/test-utils

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

Open
#747 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending triage
Dominant language
TypeScript
Stars
437
Forks
120
Avg merge
22h 52m
Merged PRs (30d)
23

Description

Environment
  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.9.3
  • CLI Version: 3.10.0
  • Nitro Version: 2.8.1
  • Package Manager: npm@10.2.3
  • Builder: -
  • User Config: devtools, modules
  • Runtime Modules: @nuxt/test-utils/module@3.11.0
  • Build Modules: -
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the StackBlitz reproduction and package.json, then inspect how @nuxt/test-utils/runtime is imported from pages/.ts. Confirm the startup error with a test file under pages and compare it after moving the file; done should define whether the warning is removed or otherwise handled without affecting app startup.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
frontend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.