From ea21ffce4c3cc217cbb80b11c709e9e44bd035c9 Mon Sep 17 00:00:00 2001 From: "Avi E. Koenig" Date: Mon, 22 Apr 2024 14:45:01 +0300 Subject: [PATCH] docs(test-runners): fix jest example to also work in ESM (#866) this is necessary because in ESM mongoose does not export `connection`, because in ESM exports cannot be modified after they are exported --- docs/guides/integration-examples/test-runners.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guides/integration-examples/test-runners.md b/docs/guides/integration-examples/test-runners.md index fe4801edf..2c006dae1 100644 --- a/docs/guides/integration-examples/test-runners.md +++ b/docs/guides/integration-examples/test-runners.md @@ -57,8 +57,8 @@ export = async function globalSetup() { } // The following is to make sure the database is clean before an test starts - await mongoose.connect(`${process.env.MONGO_URI}/${config.Database}`); - await mongoose.connection.db.dropDatabase(); + const conn = await mongoose.connect(`${process.env.MONGO_URI}/${config.Database}`); + await conn.connection.db.dropDatabase(); await mongoose.disconnect(); };