nestjs-express-cassandra
Version:
Express-cassandra module for Nest framework
42 lines (33 loc) • 942 B
text/typescript
import { INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { Server } from 'http';
import * as request from 'supertest';
import { AsyncModule } from '../../src/sample/async.module';
describe('AsyncModule - useFactory', () => {
let server: Server;
let app: INestApplication;
const payload = {
postId: 1,
title: 'Express Cassandra',
content: 'A NestJS module',
};
beforeAll(async () => {
const moduleFixture = await Test.createTestingModule({
imports: [AsyncModule],
}).compile();
app = moduleFixture.createNestApplication();
server = app.getHttpServer();
await app.init();
});
it(`CREATE: should return created entity`, () => {
return request(server)
.post('/posts')
.send(payload)
.then((res) => {
expect(res.body).toMatchObject(payload);
});
});
afterAll(async () => {
await app.close();
});
});