fix: prefix API routes
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import { INestApplication, Module } from '@nestjs/common';
|
||||
import request from 'supertest';
|
||||
import { App } from 'supertest/types';
|
||||
import { AppModule } from './../src/app.module';
|
||||
import { DatabaseModule } from './../src/database/database.module';
|
||||
import { configureApplication } from './../src/app.config';
|
||||
|
||||
@Module({})
|
||||
class TestDatabaseModule {}
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: INestApplication<App>;
|
||||
@@ -10,19 +15,27 @@ describe('AppController (e2e)', () => {
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
})
|
||||
.overrideModule(DatabaseModule)
|
||||
.useModule(TestDatabaseModule)
|
||||
.compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
configureApplication(app);
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
it('/api (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.get('/api')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
|
||||
it('/ (GET) is not an API route', () => {
|
||||
return request(app.getHttpServer()).get('/').expect(404);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await app.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user