Skip to content

Testing of Vue Components with Nuxt Auto-Import #1565

Discussion options

You must be logged in to vote

So I managed to make it work with

  • unplugin-auto-import to auto import vue stuff like ref and computed
  • unplugin-vue-components to auto import vue components

Below is the vitest.config.js file that gave me good results with vitest

import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'

export default {
  plugins: [
    vue(),
    AutoImport({
        imports: [
          'vue'
        ],  
    }), 
    Components({
      dirs: ['./components']
    }), 
  ],  
  test: {
    globals: true,
    environment: 'jsdom',
    deps: {
      inline: [/@nuxt\/test-utils-edge/],
    },  
  },  
}

You can find an ex…

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
2 replies
@remiconnesson
Comment options

@remiconnesson
Comment options

Comment options

You must be logged in to vote
4 replies
@jimbo0378
Comment options

@remiconnesson
Comment options

@remiconnesson
Comment options

@adamskeeled
Comment options

Answer selected by remiconnesson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants