Closed zhaoguangyue closed 2 months ago
The following is correct, no errors reported:
import HelloWorld from './HelloWorld.vue'; import { mount } from '@vue/test-utils';
Errors will be reported below: TypeError: Cannot destructure property 'createComponentInstance' of 'ssrUtils' as it is undefined.
import { mount } from '@vue/test-utils'; import HelloWorld from './HelloWorld.vue';
They just reversed the order
Here is the case: // helloworld.test.ts
import { expect, test } from 'vitest'; import { mount } from '@vue/test-utils'; import HelloWorld from './HelloWorld.vue'; test('renders name', async () => { const wrapper = await mount(HelloWorld, { props: { name: 'Vitest' } }); const element = wrapper.find('.aaa'); expect(element.exists()).toBe(true); });
//HelloWorld.vue
<template> <div class="aaa"> <h1>Hello {{ name }}!</h1> </div> </template> <script setup lang="ts"> defineProps<{ name: string }>(); </script>
environment: vitest Official demo https://cn.vitest.dev/guide/browser/
The following is correct, no errors reported:
Errors will be reported below: TypeError: Cannot destructure property 'createComponentInstance' of 'ssrUtils' as it is undefined.
They just reversed the order
Here is the case: // helloworld.test.ts
//HelloWorld.vue
environment: vitest Official demo https://cn.vitest.dev/guide/browser/