Closed leongaban closed 1 year ago
I am getting the following error when trying to use mount
mount
Error: [vite-node] Failed to load node_modules/vitest/dist/index
I have the latest version of vue/test-utils: "@vue/test-utils": "^2.0.2"
"@vue/test-utils": "^2.0.2"
Basic vite-config
import { fileURLToPath, URL } from 'url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' // https://vitejs.dev/config/ export default defineConfig({ test: { globals: true, }, plugins: [vue(), vueJsx()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)), }, }, })
The test:
import { mount } from '@vue/test-utils' import { expect } from 'node_modules/vitest/dist/index' import HomeHeader from '../HomeHeader.vue' test('HomeHeader renders properly', () => { expect(HomeHeader).toBeTruthy() const wrapper = mount(HomeHeader) expect(wrapper.text()).toContain('MOONHOLDINGS.XYZ') })
Test should pass
Error:
FAIL src/components/home/__tests__/HomeHeader.spec.js [ src/components/home/__tests__/HomeHeader.spec.js ] Error: [vite-node] Failed to load node_modules/vitest/dist/index
I've updated both @vue/test-utils and vitest to the latest, also watched this tutorial video: https://www.youtube.com/watch?v=snCLQmINqCU
@vue/test-utils
vitest
This repository is for issues regarding Vue-test utils V1 . For V2 related you have to go https://github.com/vuejs/test-utils
Subject of the issue
I am getting the following error when trying to use
mount
Steps to reproduce
I have the latest version of vue/test-utils:
"@vue/test-utils": "^2.0.2"
Basic vite-config
The test:
Expected behaviour
Test should pass
Actual behaviour
Error:
Possible Solution
I've updated both
@vue/test-utils
andvitest
to the latest, also watched this tutorial video: https://www.youtube.com/watch?v=snCLQmINqCU