Files
nest/integration/graphql-schema-first/e2e/graphql.spec.ts
2020-02-29 13:21:21 +01:00

41 lines
889 B
TypeScript

import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import * as request from 'supertest';
import { ApplicationModule } from '../src/app.module';
describe('GraphQL', () => {
let app: INestApplication;
beforeEach(async () => {
const module = await Test.createTestingModule({
imports: [ApplicationModule],
}).compile();
app = module.createNestApplication();
await app.init();
});
it(`should return query result`, () => {
return request(app.getHttpServer())
.post('/graphql')
.send({
operationName: null,
variables: {},
query: '{\n getCats {\n id\n }\n}\n',
})
.expect(200, {
data: {
getCats: [
{
id: 1,
},
],
},
});
});
afterEach(async () => {
await app.close();
});
});