Skip to content

Commit

Permalink
feat: 실행 환경에 따른 TypeormConfig 사용
Browse files Browse the repository at this point in the history
- app.module에서 실행 환경에 따라 typeORMConfig와 typeORMTestConfig 를 골라 실행하도록 변경
  • Loading branch information
JoonSoo-Kim committed Nov 21, 2023
1 parent b76fec3 commit 1bb072a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 5 additions & 1 deletion BE/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "dotenv/config";
import { Module } from "@nestjs/common";
import { TypeOrmModule } from "@nestjs/typeorm";
import { typeORMConfig } from "./configs/typeorm.config";
Expand All @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions BE/test/app.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1bb072a

Please sign in to comment.