我尝试根据以下内容引导一个简单的应用程序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) 我有一个基本的 Nestjs - Mongoose - Graphql api,我定义了两个模式:User和Event
//USER Schema
@Schema()
export class User extends Document {
@Prop()
username: string;
@Prop({ required: true })
password: string;
@Prop({ required: true, unique: true })
email: string;
@Prop({ required: true, unique: true })
handle: string;
@Prop()
avatar: string;
}
export const UserSchema = SchemaFactory.createForClass(User);
Run Code Online (Sandbox Code Playgroud)
//EVENT schema
@Schema()
export class Event extends Document {
@Prop({
type: MongooseSchema.Types.ObjectId,
ref: User.name,
required: true,
})
creator: GqlUser;
@Length(5, 30)
@Prop({ required: true })
title: string; …Run Code Online (Sandbox Code Playgroud)