import { INestApplication, ValidationPipe } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import request from 'supertest'; import { AppModule } from '../src/app.module'; describe('Passenger API (e2e)', () => { let app: INestApplication; beforeAll(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ imports: [AppModule], }).compile(); app = moduleFixture.createNestApplication(); app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true })); await app.init(); }); afterAll(async () => { await app.close(); }); it('GET /stations returns 200', () => { return request(app.getHttpServer()).get('/stations').expect(200); }); it('GET /search returns 200', () => { return request(app.getHttpServer()).get('/search').expect(404); // POST only }); it('POST /auth/login with bad credentials returns 401', () => { return request(app.getHttpServer()) .post('/auth/login') .send({ email: 'nobody@test.com', password: 'wrong' }) .expect(401); }); });