Skip to content

Commit 923fbb3

Browse files
committed
fix: resolve strapi instance reference in test helpers
Fix ReferenceError in cleanupStrapi() by using the local instance variable instead of global strapi. Add null check to prevent cleanup errors when instance is not initialized.
1 parent 6a504a2 commit 923fbb3

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

playground/__tests__/helpers.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ async function setupStrapi() {
1515
}
1616

1717
async function cleanupStrapi() {
18-
const dbSettings = strapi.config.get('database.connection');
18+
if (!instance) {
19+
return;
20+
}
21+
22+
const dbSettings = instance.config.get('database.connection');
1923

2024
// close server to release the db-file.
21-
await strapi.server.httpServer.close();
25+
await instance.server.httpServer.close();
2226

2327
// close the connection to the database before deletion.
24-
await strapi.db.connection.destroy();
28+
await instance.db.connection.destroy();
2529

2630
// delete test database after all tests have completed.
2731
if (dbSettings && dbSettings.connection && dbSettings.connection.filename) {

0 commit comments

Comments
 (0)