Files
backend/test/app.e2e-spec.ts
T
2026-08-02 17:21:34 +03:30

38 lines
949 B
TypeScript

import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication, ValidationPipe } from '@nestjs/common';
import request from 'supertest';
import { App } from 'supertest/types';
import { AppModule } from './../src/app.module';
describe('Auth (e2e)', () => {
let app: INestApplication<App>;
beforeEach(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
app.setGlobalPrefix('api/v1');
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
}),
);
await app.init();
});
it('rejects login with invalid body', () => {
return request(app.getHttpServer())
.post('/api/v1/auth/login')
.send({})
.expect(400);
});
afterEach(async () => {
await app.close();
});
});