diff --git a/server/tests/setup.js b/server/tests/setup.js index c1bc201..5e9a41e 100644 --- a/server/tests/setup.js +++ b/server/tests/setup.js @@ -103,7 +103,23 @@ async function teardownTestEnvironment() { */ async function cleanDatabase() { if (sequelize) { - await sequelize.sync({ force: true }); + try { + // Drop all tables and recreate them + await sequelize.drop(); + await sequelize.sync({ force: true }); + + // Verify tables are clean + const tableNames = Object.keys(sequelize.models); + for (const tableName of tableNames) { + const count = await sequelize.models[tableName].count(); + if (count > 0) { + console.warn(`Warning: ${tableName} table not properly cleaned, has ${count} records`); + } + } + } catch (error) { + console.error('Error cleaning database:', error); + throw error; + } } }