Skip to content

Commit

Permalink
fix: 통합테스트에서 pinoLogger를 모킹하여 필요없는 로그가 나오지 않도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
koomchang committed Dec 5, 2024
1 parent 7e1dca8 commit 14a2550
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 9 additions & 4 deletions backend/test/config/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Test, TestingModule } from '@nestjs/testing';
import { initializeTransactionalContext } from 'typeorm-transactional';
import { initDataSource } from '@test/config/datasource.config';
import { AppModule } from '@src/AppModule';
import { PinoLogger } from 'nestjs-pino';

interface TestSetup {
app: INestApplication;
Expand All @@ -22,6 +23,10 @@ export async function initializeIntegrationTestEnvironment(): Promise<TestSetup>
})
.overrideProvider(DataSource)
.useValue(dataSource)
.overrideProvider(PinoLogger)
.useValue({
error: jest.fn(),
})
.compile();
const app = module.createNestApplication();
app.useGlobalPipes(new ValidationPipe({ transform: true }));
Expand All @@ -44,10 +49,10 @@ export async function truncateTables(dataSource: DataSource) {
await queryRunner.query('SET FOREIGN_KEY_CHECKS = 0;');

const tables = await queryRunner.query(`
SELECT TABLE_NAME
FROM information_schema.tables
WHERE table_schema = DATABASE();
`);
SELECT TABLE_NAME
FROM information_schema.tables
WHERE table_schema = DATABASE();
`);

for (const { TABLE_NAME } of tables) {
await queryRunner.query(`TRUNCATE TABLE \`${TABLE_NAME}\`;`);
Expand Down
6 changes: 5 additions & 1 deletion backend/test/course/course.service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ describe('CourseService', () => {
currentPage,
pageSize,
);
expect(result).toEqual(expectedResponse);
expect(result).toEqual(
expect.objectContaining({
courses: expectedResponse.courses,
}),
);
});

describe('특정 코스를 조회할 때', () => {
Expand Down

0 comments on commit 14a2550

Please sign in to comment.