Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing in devtools fails #989

Open
yuuzora opened this issue Oct 23, 2024 · 1 comment
Open

Testing in devtools fails #989

yuuzora opened this issue Oct 23, 2024 · 1 comment

Comments

@yuuzora
Copy link

yuuzora commented Oct 23, 2024

Environment

  • Operating System: Darwin
  • Node Version: v20.16.0
  • Nuxt Version: 3.13.2
  • CLI Version: 3.15.0
  • Nitro Version: 2.9.7
  • Package Manager: [email protected]
  • Builder: -
  • User Config: default
  • Runtime Modules: @nuxt/test-utils/[email protected]
  • Build Modules: -

Reproduction

Create a new Nuxt projet, install test suite following this link
Create a simple test and run pnpm dev.

Open devtools and run the tests

Describe the bug

Tests run from the devtools or the Vitest UI url on pnpm dev are broken with TypeError: Cannot read properties of undefined (reading 'vueApp')
Image

However, running vitest --ui manually is working
Image

Additional context

This happens even with the most basic vitest config file and nuxt config

import { fileURLToPath } from 'node:url'
import { defineVitestConfig } from '@nuxt/test-utils/config'

export default defineVitestConfig({
    test: {
        environment: 'nuxt',
    },
})
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
  compatibilityDate: '2024-04-03',
  devtools: { enabled: true },
  modules: [
    '@nuxt/test-utils/module'
  ]
})

Spec file:

import { it } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import App from '../app.vue'

it('can mount some component', async () => {
    await mountSuspended(App)
})

Since test are working by running vitest --ui it isn't blocking but it kinda defeat the whole purpose of using @nuxt/test-utils/module, which seemed very convenient

Logs

No response

@jmescode-te
Copy link

jmescode-te commented Oct 28, 2024

I am having the same issue, but my error is window is not defined

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

No branches or pull requests

2 participants