小编bin*_*n k的帖子

如何使用 GRAPHQL 测试 e2e Nestjs API

当我通过 graphql-playground 创建我的所有者时,它工作正常,\n但我的测试失败并回复我“body.data.createOwner 未定义”,没有数据。

\n
// owner.e2e.spec.ts\ndescribe('Owner test (e2e)', () => {\n    let app: INestApplication;\n\n    beforeAll(async () => {\n        const moduleRef = await Test.createTestingModule({\n            imports: [\n                GraphQLModule.forRoot({\n                    autoSchemaFile: join(process.cwd(), 'src/schema.gql'),\n                }),\n                OwnerModule,\n                DatabaseModule\n            ]\n        }).compile();\n        app = moduleRef.createNestApplication();\n        await app.init();\n    });\n\n    afterAll(async () => {\n        await app.close();\n    })\n\n    const createOwnerQuery = `\n           mutation createOwner($OwnerInput: OwnerInput!) {\n            createOwner(ownerInput: $OwnerInput) {\n              _id\n              name\n              firstname\n              email\n              password\n              firstsub\n              expsub\n              createdAt\n              updatedAt\n            }\n          }\n    `;\n   \n    let id: string = '';\n\n    it('createOwner', () => …
Run Code Online (Sandbox Code Playgroud)

testing e2e-testing graphql nestjs graphql-mutation

6
推荐指数
1
解决办法
5426
查看次数

标签 统计

e2e-testing ×1

graphql ×1

graphql-mutation ×1

nestjs ×1

testing ×1