title: How to call DB connection in beforeAll() and DB connection close in afterAll()
body: <p>I am new to Jest and TypeORM and want to develop Database validation framework using typeorm and Jest. How to call three DB connections instance in beforeAll().</p>
  
  <p>This is for a new framework on for Database Validation using TypeORM and Jest Ormconfig.json has details of three database and has a .ts class for databaseconnectivity and a test class.</p>
  
  <p>ormconfig.json</p>
  
  <pre><code>[{
    "name": "default",
    "type": "mysql",
    "host": "127.0.01",
    "port": 3306,
    "username": "sdf",
    "password": "uuehfldjskh",
    "database": "ifsdjh",
    "synchronize": true,
    "logging": false,
    "entities": [
      "src/entity/**/*.ts"
    ],
    "migrations": [
      "src/migration/**/*.ts"
    ],
    "subscribers": [
      "src/subscriber/**/*.ts"
    ],
    "cli": {
      "entitiesDir": "src/entity",
      "migrationsDir": "src/migration",
      "subscribersDir": "src/subscriber"
    }
  },
    {
      "name": "hello",
      "type": "mysql",
      "host": "127.0.01",
      "port": 3306,
      "username": "weqwe",
      "password": "das",
      "database": "dsfds",
      "synchronize": true,
      "logging": false,
      "entities": [
        "src/entity/**/*.ts"
      ],
      "migrations": [
        "src/migration/**/*.ts"
      ],
      "subscribers": [
        "src/subscriber/**/*.ts"
      ],
      "cli": {
        "entitiesDir": "src/entity",
        "migrationsDir": "src/migration",
        "subscribersDir": "src/subscriber"
      }
    }
  ]
  </code></pre>
  
  <p>createConnection.ts</p>
  
  <pre><code>import {createConnection, getConnectionOptions} from "typeorm";
  
  export const createConnection = async  () =&gt; {
      const createConnectionOptions = await getConnectionOptions(process.env.NODE_ENV);
      return createConnection({...createConnectionOptions,name:"default"});
  }
  </code></pre>
  
  <p>testClass.ts</p>
  
  <pre><code>import {Patches} from "../entity/Patches";
  import {createConnection} from "../utils/createConnection";
  
  test('Query with getRepository()', async () =&gt; {
      jest.setTimeout(100000);
      const connection = await createConnection();
      const Count = await connection.getRepository(User).count();
      console.log(Count);
      expect(Count).toEqual(32);
      await connection.close();
  })
  </code></pre>
  
  <p>How can i move connection to database before every test - </p>
  
  <pre><code>beforeAll(){
  connectionDB();
  }
  
  test()
  {
     connection(db1) //connect to DB1
     /** Do operation on DB1 **/
     connection(db2) //connect to DB2
     /** Do operation on DB2 **/
     Compare both result of DB1 and DB2
  }
  
  afterAll()
  {
  connectionDB().close();
  }
  </code></pre>