Skip to content

Conversation

ExEr7um
Copy link
Contributor

@ExEr7um ExEr7um commented Oct 3, 2025

πŸ”— Linked issue

None.

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Problem

The setupImportMocking function was failing when presets contained string values (e.g., vitest) instead of objects with an imports property.

export default defineNuxtConfig({
  imports: { presets: ["vitest"] },
})

This caused a TypeError when trying to access p.imports on string presets, breaking test execution.

⎯⎯⎯⎯ Startup Error ⎯⎯⎯⎯
TypeError: Cannot read properties of undefined (reading 'includes')

Solution

Added optional chaining (?.) to safely check if the imports property exists before calling .includes('setInterval'). This prevents errors when presets are strings rather than objects with an imports array.

@ExEr7um ExEr7um requested a review from danielroe as a code owner October 3, 2025 16:48
Copy link

pkg-pr-new bot commented Oct 3, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/test-utils@1433

commit: 2b351f1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants