Skip to content

[vite:vue] MagicString is not a constructor #1690

@danekslama

Description

@danekslama

Environment

Operating system Linux 6.6.87.2-microsoft-standard-WSL2
CPU AMD Ryzen 9 6900HX with Radeon Graphics (16 cores)
Node.js version v24.14.1
nuxt/cli version 3.35.1
Package manager pnpm@10.33.0
Nuxt version 4.4.4
Nitro version 2.13.4
Builder vite@7.3.3
Config app, compatibilityDate, css, devtools, eslint, googleFonts, modules, ogImage, runtimeConfig, security, shadcn, vite
Modules @nuxt/icon@2.2.1, @nuxt/eslint@1.15.2, @nuxt/image@2.0.0, @nuxt/test-utils/module@4.0.3, @nuxtjs/google-fonts@3.2.0, @nuxtjs/seo@3.4.0, @vueuse/nuxt@14.2.1, @pinia/nuxt@0.11.3, nuxt-security@2.5.1, reka-ui/nuxt@2.9.1, shadcn-nuxt@2.4.3

Reproduction

https://stackblitz.com/edit/github-wjqrqsms?file=test%2Fnuxt%2Fapp.spec.ts,vitest.config.ts,nuxt.config.ts

Describe the bug

I'm getting a 'MagicString is not a constructor' error when calling the setup function inside a test. I haven't been able to run the integration tests for our simple login. Am I doing something wrong? I also tested this in a minimal reproduction on StackBlitz, and it throws the same exception.

import { $fetch, setup } from '@nuxt/test-utils'

import { describe, expect, it } from 'vitest'

describe('Family Tree Integration Tests', async() => {
  let token: string

  await setup({
    server: true
  })

  it('should login and get a token', async() => {
  .....
  })
})

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions