Jest tests leaking due to improper teardown

As suggested in the warning, add --detectOpenHandles option to jest’s script in package.json file:

"scripts": {
    "test": "jest --watchAll --detectOpenHandles"
  }

Dont forget to stop then start the server !

This solution can work whatever your problem. But, according to your case, your problem is coming from the redis connection. You need to close redis at the end of the test:

import { redis } from "redis_file_path";

afterAll(async () => {
    await redis.quit();
});

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)