Is there an example of Vitest with Nuxt3 and using .vue components? #1325
Answered
by
sheremet-va
jasondonnellya
asked this question in
Q&A
-
Tried running this: import { mount } from '@vue/test-utils'
import { it } from 'vitest'
import Container from './Container.vue'
it('should work', (ctx) => {
// prints name of the test
const container = mount(Container)
console.log(ctx.meta.name)
}) And get this error:
In nuxt.config.ts I tried setting this up as with the @vitejs/plugin-vue and doesn't work: import { defineNuxtConfig } from 'nuxt'
import vue from '@vitejs/plugin-vue'
export default defineNuxtConfig({
...
/**
* Vite Proxy
* (https://vitejs.dev/config/#server-proxy)
*/
vite: {
server: {
proxy: {
'/uploads': `${process.env.API_URL}`
}
},
test: {
plugins: [vue()]
}
}
}) But it doesn't seem to make a difference. |
Beta Was this translation helpful? Give feedback.
Answered by
sheremet-va
May 17, 2022
Replies: 1 comment 4 replies
-
You can see the example in their docs: https://v3.nuxtjs.org/guide/going-further/testing/ Maybe we will add a Nuxt example in Vitest, PR welcome! |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
jasondonnellya
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can see the example in their docs: https://v3.nuxtjs.org/guide/going-further/testing/
Maybe we will add a Nuxt example in Vitest, PR welcome!