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

TypeError when Setting Up Vitest #3213

Open
brenodanyel opened this issue Jan 31, 2025 · 2 comments
Open

TypeError when Setting Up Vitest #3213

brenodanyel opened this issue Jan 31, 2025 · 2 comments
Labels
bug Something isn't working v3 #1289

Comments

@brenodanyel
Copy link

Environment


  • Operating System: Linux
  • Node Version: v20.17.0
  • Nuxt Version: -
  • CLI Version: 3.21.1
  • Nitro Version: -
  • Package Manager: [email protected]
  • Builder: -
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Version

3.0.0-alpha.10

Reproduction

  • Start a new project with the starter CLI:
    npx nuxi init -t github:nuxtlabs/nuxt-ui3-vue-starter test-app

  • Install vitest and vue test-utils
    bun add -D vitest @vue/test-utils

  • Add test script to package.json
    "test": "vitest"

  • Run the test script

Description

I'm encountering a TypeError while trying to set up Vitest in my project (Vue). The error message is as follows:

TypeError: Package import specifier "#imports" is not defined in package 
/home/xxxx/test-app/node_modules/@nuxt/ui/package.json imported from 
/home/xxxx/test-app/node_modules/@nuxt/ui/dist/runtime/composables/useComponentIcons.js

Additional context

No response

Logs

TypeError: Package import specifier "#imports" is not defined in package /home/xxxx/test-app/node_modules/@nuxt/ui/package.json imported from /home/xxxx/test-app/node_modules/@nuxt/ui/dist/runtime/composables/useComponentIcons.js
@brenodanyel brenodanyel added bug Something isn't working triage labels Jan 31, 2025
@averrois
Copy link

averrois commented Jan 31, 2025

That's weird I tried to do the same but I did not got the same logs, instead the test just passed

@brenodanyel
Copy link
Author

brenodanyel commented Jan 31, 2025

Hey @averrois! I forgot to mention that this error only happens when we call mount for a component that internally uses any Nuxt UI component

With the starter, you can call mount on App.vue, since it uses UApp and UButton.

// src/App.spec.ts

import { describe, it, expect } from 'vitest';
import { mount } from '@vue/test-utils';
import App from './App.vue';

describe('App', () => {
	it('should render', () => {
		const wrapper = mount(App);
		expect(wrapper.exists()).toBe(true);
	});
});

Can you please test if it still working for you?

@HugoRCD HugoRCD removed the triage label Feb 1, 2025
@benjamincanac benjamincanac added the v3 #1289 label Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v3 #1289
Projects
None yet
Development

No branches or pull requests

4 participants