diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 236e183..aa47e63 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: CI - Run Tests +name: Run Tests on: push: @@ -24,8 +24,7 @@ jobs: - name: Install Dependencies run: npm ci - - name: Set Environment Variables - run: echo "NODE_ENV=test" >> $GITHUB_ENV - - name: Run Tests + env: + NODE_ENV: test run: npm test diff --git a/src/tests/setup.ts b/src/tests/setup.ts index f194730..373f7b9 100644 --- a/src/tests/setup.ts +++ b/src/tests/setup.ts @@ -1,29 +1,33 @@ import AppDataSource from "../config/ormconfig"; beforeAll(async () => { + console.log("Initializing database..."); if (!AppDataSource.isInitialized) { await AppDataSource.initialize(); } + console.log("Database initialized."); if (process.env.NODE_ENV === "test") { + console.log("Synchronizing database..."); await AppDataSource.synchronize(); - - const queryRunner = AppDataSource.createQueryRunner(); - const tables = await queryRunner.getTables(); - await queryRunner.release(); + console.log("Database synchronized."); } }); afterEach(async () => { + console.log("Clearing database..."); const entities = AppDataSource.entityMetadatas; for (const entity of entities) { const repository = AppDataSource.getRepository(entity.name); await repository.clear(); } + console.log("Database cleared."); }); afterAll(async () => { + console.log("Destroying database..."); if (AppDataSource.isInitialized) { await AppDataSource.destroy(); } + console.log("Database destroyed."); });