nuxt / nuxt/test-utils

Vue Router warning when page / is not defined

Open
#1,366 3 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: Darwin
  • Node Version: v22.14.0
  • Nuxt Version: 3.17.7
  • CLI Version: 3.26.2
  • Nitro Version: 2.12.2
  • Package Manager: npm@11.2.0
  • Builder: -
  • User Config: compatibilityDate, devtools, modules
  • Runtime Modules: @nuxt/test-utils/module@3.19.2
  • Build Modules: -

Reproduction

https://github.com/JBustin/nuxt3-test-utils

Sorry, I would like to share a reproduction on Stackblitz, but I failed to get an effective install of nuxt3 + @nuxt/test-utils: https://stackblitz.com/edit/nuxt-starter-mygjuknd?file=package.json

Describe the bug

If I don't have any / page, we experiment some router warnings during test.

stderr | components/Header.nuxt.spec.ts
[Vue Router warn]: No match found for location with path "/"

stderr | components/Header.nuxt.spec.ts
[Vue Router warn]: No match found for location with path "/"

stderr | components/Header.nuxt.spec.ts
[nuxt] error caught during app initialization H3Error: Page not found: /
Additional context

Additionally, we expect to be able to mock the current route during the tests, because we have some different behavior regarding the format of the current route.

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 reproduction at github.com/JBustin/nuxt3-test-utils and the failing components/Header.nuxt.spec.ts test. Investigate test startup when no / page exists, along with the requested ability to mock the current route. Done means the test no longer emits the Vue Router or Nuxt page-not-found warnings and route mocking works for the described behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.