我尝试根据以下内容引导一个简单的应用程序Vue3,,ViteVitest
我还安装了 vue 3 兼容版本的vue test utils来测试 vue 组件。
\n我在尝试复制文档中的基本示例时遇到错误:
\nimport { mount } from "@vue/test-utils";\nimport { expect, test } from \'vitest\'\n\n\n// The component to test\nconst MessageComponent = {\n template: "<p>{{ msg }}</p>",\n props: ["msg"],\n};\n\ntest("displays message", () => {\n const wrapper = mount(MessageComponent, {\n props: {\n msg: "Hello world",\n },\n });\n\n // Assert the rendered text of the component\n expect(wrapper.text()).toContain("Hello world");\n});\n\nRun Code Online (Sandbox Code Playgroud)\n FAIL src/tests/hello-world.test.ts > displays message\nReferenceError: document is not defined\n …Run Code Online (Sandbox Code Playgroud)