From 14a2550b84b330e202d933fc9b2bdbf8f7fc054c Mon Sep 17 00:00:00 2001 From: koomchang Date: Thu, 5 Dec 2024 20:59:34 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=86=B5=ED=95=A9=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EC=97=90=EC=84=9C=20pinoLogger=EB=A5=BC=20=EB=AA=A8?= =?UTF-8?q?=ED=82=B9=ED=95=98=EC=97=AC=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EB=A1=9C=EA=B7=B8=EA=B0=80=20=EB=82=98=EC=98=A4?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/test/config/utils.ts | 13 +++++++++---- backend/test/course/course.service.test.ts | 6 +++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/test/config/utils.ts b/backend/test/config/utils.ts index 1eafd3aa..078e709f 100644 --- a/backend/test/config/utils.ts +++ b/backend/test/config/utils.ts @@ -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; @@ -22,6 +23,10 @@ export async function initializeIntegrationTestEnvironment(): Promise }) .overrideProvider(DataSource) .useValue(dataSource) + .overrideProvider(PinoLogger) + .useValue({ + error: jest.fn(), + }) .compile(); const app = module.createNestApplication(); app.useGlobalPipes(new ValidationPipe({ transform: true })); @@ -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}\`;`); diff --git a/backend/test/course/course.service.test.ts b/backend/test/course/course.service.test.ts index 555f43b7..aa4ac7b8 100644 --- a/backend/test/course/course.service.test.ts +++ b/backend/test/course/course.service.test.ts @@ -183,7 +183,11 @@ describe('CourseService', () => { currentPage, pageSize, ); - expect(result).toEqual(expectedResponse); + expect(result).toEqual( + expect.objectContaining({ + courses: expectedResponse.courses, + }), + ); }); describe('특정 코스를 조회할 때', () => {