diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 93b3a9f..9388e60 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,9 +45,6 @@ jobs: cache: 'pnpm' - name: Install dependencies run: pnpm install --no-frozen-lockfile - - name: Display Variables - run: - echo "REDIS_HOST - ${{ env.REDIS_HOST }}, REDIS_PORT - ${{ env.REDIS_PORT }}, REDIS_USER - ${{ env.REDIS_USER }}, REDIS_PASSWORD - ${{ env.REDIS_PASSWORD }}, DB_HOST - ${{ env.DB_HOST }}, DB_PORT - ${{ env.DB_PORT }}, DB_NAME - ${{ env.DB_NAME }}, DB_USERNAME - ${{ env.DB_USERNAME }}, DB_PASSWORD - ${{ env.DB_PASSWORD }}" - name: Run lint run: pnpm lint - name: Run tests diff --git a/package.json b/package.json index 2421f5e..7e2513e 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "db:create": "pnpm run build && NODE_ENV=development npx sequelize-cli db:create", "db:migrate:up": "pnpm run build && NODE_ENV=development npx sequelize-cli db:migrate", "db:migrate:undo": "pnpm run build && NODE_ENV=development npx sequelize-cli db:migrate:undo", - "test": "NODE_ENV=test TEST_MODEL=real jest --runInBand", + "test": "NODE_ENV=test TEST_MODEL=real jest --runInBand --detectOpenHandles", "test:watch": "NODE_ENV=test TEST_MODEL=real jest --runInBand --watch", "lint": "eslint ./src/**/*" }, diff --git a/src/app.ts b/src/app.ts index da3927f..c7b5e5c 100644 --- a/src/app.ts +++ b/src/app.ts @@ -24,6 +24,7 @@ import { import { TYPES } from 'di/types'; import { AuthController, UserController } from 'controllers'; +import { RedisClient } from 'configs/redis.config'; @injectable() export class App { @@ -40,6 +41,8 @@ export class App { private rateLimitHandler: RateLimitHandler, @inject(TYPES.SessionHandler) private sessionHandler: SessionHandler, + @inject(TYPES.RedisClient) + private redisClient: RedisClient, ) {} public async initialize() { @@ -66,8 +69,9 @@ export class App { }); } - public stop(callback: (err?: Error) => void) { + public shutdown(callback: (err?: Error) => void) { sequelize.close(); + this.redisClient.close(); this.httpServer?.close(callback); } diff --git a/src/tests/server.test.ts b/src/tests/server.test.ts index fa96022..58386f6 100644 --- a/src/tests/server.test.ts +++ b/src/tests/server.test.ts @@ -18,7 +18,7 @@ describe('Server Start', () => { }); afterAll((done) => { - app.stop(done); + app.shutdown(done); done(); });