diff --git a/BE/src/app.module.ts b/BE/src/app.module.ts index fbbc3fe..65cdb97 100644 --- a/BE/src/app.module.ts +++ b/BE/src/app.module.ts @@ -1,3 +1,4 @@ +import "dotenv/config"; import { Module } from "@nestjs/common"; import { TypeOrmModule } from "@nestjs/typeorm"; import { typeORMConfig } from "./configs/typeorm.config"; @@ -8,10 +9,13 @@ import { IntroduceModule } from "./introduce/introduce.module"; import { ShapesModule } from "./shapes/shapes.module"; import { ShapesRepository } from "./shapes/shapes.repository"; import { UsersRepository } from "./users/users.repository"; +import { typeORMTestConfig } from "./configs/typeorm.test.config"; @Module({ imports: [ - TypeOrmModule.forRoot(typeORMConfig), + TypeOrmModule.forRoot( + process.env.NODE_ENV === "test" ? typeORMTestConfig : typeORMConfig, + ), UsersModule, DiariesModule, AuthModule, diff --git a/BE/test/app.e2e-spec.ts b/BE/test/app.e2e-spec.ts index fd5d51a..b64a1b9 100644 --- a/BE/test/app.e2e-spec.ts +++ b/BE/test/app.e2e-spec.ts @@ -2,15 +2,13 @@ import { Test, TestingModule } from "@nestjs/testing"; import { INestApplication } from "@nestjs/common"; import * as request from "supertest"; import { AppModule } from "../src/app.module"; -import { TypeOrmModule } from "@nestjs/typeorm"; -import { typeORMTestConfig } from "src/configs/typeorm.config"; describe("AppController (e2e)", () => { let app: INestApplication; beforeEach(async () => { const moduleFixture: TestingModule = await Test.createTestingModule({ - imports: [TypeOrmModule.forRoot(typeORMTestConfig), AppModule], + imports: [AppModule], }).compile(); app = moduleFixture.createNestApplication();