Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Nuxt v4.6.0 nightly: `@nuxt/test-utils/module` causes colocated tests to be registered as app files, causing import-protection errors during dev

Open
#1,833 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@yamachi4416 is already working on this.

Since Oct 3, 2026.

  • #1834 by @yamachi4416 — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
nuxtjs, typescript

Research direction

Start with src/module/mock.ts around lines 44–49 and reproduce the failure using the linked StackBlitz setup with @nuxt/test-utils/module enabled and colocated tests. Trace how the module graph registers tests during nuxt dev, then verify that files such as tests/helpers/nuxt-composable.ts are no longer treated as app files or rejected by import protection.

Written by the indexing model from the issue text.

Description

pending triage
Environment

Nuxt project info:

Operating system Linux 5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/154.0.0.0 Safari/537.36
CPU Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz (8 cores)
Node.js version v22.22.3
nuxt/cli version 4.0.0-20261002-114954-4cba365
Package manager [email protected]
Nuxt version 4.6.0-29844781.aec739e9
Nitro version 2.13.4
Builder [email protected]
Config compatibilityDate, devtools, modules
Modules @nuxt/test-utils/[email protected]
Reproduction

https://stackblitz.com/edit/github-95gnhfsg

--> Only shows the general setup. Starting the dev server in the Stackblitz container causes some error in the Nuxt cli package which I didn't manage to solve.

Describe the bug

Hello,
I am currently trying out the latest Nuxt 4.6.0 nightly and encounter some problems related to my test setup. I use colocated tests in my project (__tests__ folders next to the code they are testing) which work fine with Nuxt 4.5. However in Nuxt 4.6 I get the following error on running nuxt dev:

4:59:44 PM ✖ Error: This module cannot be imported in the Vue part of your app. [importing `@nuxt/test-utils/runtime` from
▎              `tests/helpers/nuxt-composable.ts`]
▎              
▎              Code:
▎              > 1 | import { mountSuspended } from '@nuxt/test-utils/runtime';
▎              |                                ^
▎            
▎              generated code:
▎              › 1 │ import { mountSuspended } from "@nuxt/test-utils/runtime";
▎                  │                               ^
▎                2 │ import { defineComponent } from "vue";
▎                3 │ import { registerMountCleanup } from "../utils/mount-cleanup";
▎            
▎              at <anonymous> tests/helpers/nuxt-composable.ts (generated 1:31)

This helper is used in some of my test files.

I assume something regarding the import protection or how the module graph is scanned has changed in Nuxt 4.6 which exposes this problem.

The issue itself is probably caused by this section here:
https://github.com/nuxt/test-utils/blob/5498f4b9b401e62871b3a36b72959d8d535d63d2/src/module/mock.ts#L44-L49

Removing '@nuxt/test-utils/module' from the modules in the nuxt config solves the problem.

Additional context

No response

Logs

Dominant language
TypeScript
Stars
440
Forks
120
Avg merge
5d 22h
Merged PRs (30d)
22

Getting set up

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.

More from nuxt/test-utils

All issues in nuxt/test-utils

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.