jeudi 17 décembre 2020

TypeORM MongoDB is not dropped when tests are completed

I'm having issue with dropping the db after e2e tests are completed here is the code example:

beforeAll(async done => {
    const connectionManager = getConnectionManager();
    const connection = connectionManager.create({
        type: 'mongodb',
        url: 'mongodb://localhost:27017',
        synchronize: true,
        appname: 'my-db',
        database: 'my-data-base',
    });
    await connection.connect();
    done();
});

afterAll(async done => {
    await getConnection().dropDatabase();

    done();
});

If I drop it manually from any tool, it works fine, but now records are still persisting.

Actual: After all of the tests are completed I want to drop the database, but tables with records are still existing.

Expected: Database to be clean.

Packages:

 "@nestjs/typeorm": "^7.1.4",
 "mongodb": "^3.6.2",
 "typeorm": "^0.2.28"
 "supertest": "^6.0.1",

Aucun commentaire:

Enregistrer un commentaire