Skip to content

Update from 3.18 to 3.19 changed default configuration, causing tests without .nuxt. to not be included #1296

Closed
@felix-dolderer

Description

@felix-dolderer

Environment

  • Operating System: Darwin
  • Node Version: v22.12.0
  • Nuxt Version: 3.17.3
  • CLI Version: 3.25.1
  • Nitro Version: 2.11.12
  • Package Manager: bun@1.2.14
  • Builder: -
  • User Config: modules, typescript, alias, compatibilityDate, css, devtools, experimental, future, rootDir, vite, hanko, i18n
  • Runtime Modules: ~~/modules/startup-check, @nuxt/fonts@0.11.4, @nuxt/icon@1.13.0, @nuxt/image@1.10.0, @nuxt/test-utils@3.19.0, @nuxt/test-utils/module@3.19.0, @nuxt/ui@3.1.2, @nuxtjs/i18n@9.5.4, @nuxtjs/hanko@1.0.0
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-d5xpujkj?file=test%2Fbug.test.ts

Describe the bug

I got some trouble when I updated from 3.18 to 3.19

After the update only .nuxt.test.ts tests are run by vitest.

To restore the previous behaviour (also running tests unrelated to nuxt), I now need to set environment "nuxt", which feels really unintiutive.

export default defineVitestConfig({
  test: {
    environment: "nuxt",
  },
})

Additional context

No response

Logs

Activity

added theissue type on May 17, 2025
danielroe

danielroe commented on May 17, 2025

@danielroe
Member

this is not intended and is likely due to the move from environmentMatchGlobs to workspace...

tobiashm

tobiashm commented on May 19, 2025

@tobiashm
julschne

julschne commented on May 22, 2025

@julschne
danielroe

danielroe commented on May 22, 2025

@danielroe
Member

It's not a breaking change; it's a bug.

karladler

karladler commented on May 30, 2025

@karladler

IMHO this is breaking the functionality of the module that it should either be a major version or the version needs to be rolled back.

lutejka

lutejka commented on Jun 2, 2025

@lutejka
Contributor

Hey @danielroe I also think this is caused by moving to workspaces. My PR gets it working again for most cases, however I needed to import import { defineNuxtConfig } from 'nuxt/config' in nuxt.config.ts of the vitest-full example.

Not sure why tho

th1nkgr33n

th1nkgr33n commented on Jun 5, 2025

@th1nkgr33n

Until the Fix is applied to the next version, a workaround would be to adapt the vitest.config files

test: {
    // Include both .nuxt.test.ts and .test.ts files
    include: [
      '**/*.nuxt.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
      '**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}',
      '{test,tests}/nuxt/**.*',
    ],
}
lutejka

lutejka commented on Jun 5, 2025

@lutejka
Contributor

Yes this should work in most cases. However, I think this will run all tests in the nuxt environment. If you depend on not running in the nuxt env, this might not be enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @tobiashm@karladler@th1nkgr33n@lutejka@julschne

      Issue actions

        Update from 3.18 to 3.19 changed default configuration, causing tests without .nuxt. to not be included · Issue #1296 · nuxt/test-utils