Files
nest/integration/graphql-code-first/e2e/code-first.spec.ts

37 lines
825 B
TypeScript

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