Skip to content

Vitest 4 broken for SVG imports #14626

@teacher987

Description

@teacher987

Astro Info

Astro                    v5.15.1
Vite                     v6.4.1
Node                     v24.7.0
System                   macOS (arm64)
Package Manager          npm
Output                   server
Adapter                  @astrojs/node (v9.5.0)

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I tried to upgrade to Vitest 4. Some tests work fine, but those that cover components which import svg files break.

The error I get is:

TypeError: Cannot read properties of undefined (reading 'DEV')

The file that throws the error is:

// node_modules/astro/dist/assets/runtime.js:12
if (import.meta.env.DEV) {
  ...
}

What's the expected result?

Vitest 4 tests covering components that have SVGs shouldn't break.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-dmphmzqz?file=vitest.config.ts,src%2Fcomponents%2FWelcome.test.ts&on=stackblitz

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in reviewHas been triaged but not yet decided if it is a bug or not.needs responseIssue needs response from OP

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions