Skip to content

Vitest workspaces in a monorepo doesn't work. #1307

Open
@zfeher

Description

@zfeher

Environment


  • Operating System: Windows_NT
  • Node Version: v22.13.1
  • Nuxt Version: 3.17.4
  • CLI Version: 3.25.1
  • Nitro Version: 2.11.12
  • Package Manager: npm@11.4.1
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

repo - runs when checked out locally (npm i && npm t)
stackblitz - doesn't run for some reason, maybe something related to the stackblitz template provided by this issue creation tool.

Describe the bug

When we are in a monorepo with multiple packages (regulars, nuxt layers) and we want to run tests from root the nuxt layer package tests are failing because nuxt features doesn't work (no auto import, no layer aliases, ...).

At root level we have a plain vitest config using defineConfig and setting workspace option. This correctly picks up individual package vitest.config.ts files. Nuxt layer packages use defineVitestProject.

Running npm t in the actual nuxt layer packages everything works as it should (nuxt features are working).

It is also interesting that we had to install nuxt at root level, but maybe that is fine.

Another interesting thing we noticed that each nuxt layer package runs test from all layers which we don't want so added exlude patterns in those vitest configs.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions