Skip to content

Commit cd5177a

Browse files
committed
feat: enhance global setup by cleaning entire persistent_data directory before tests
1 parent 8f8fd2e commit cd5177a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

services/backend/tests/globalSetup.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ export default async function globalSetup() {
1818
process.env.COOKIE_SECRET = 'test-cookie-secret-for-jest'; // Add cookie secret for tests
1919
process.env.DEPLOYSTACK_FRONTEND_URL = 'http://localhost:5174'; // Add dummy frontend URL for tests
2020

21-
// Clean up persistent data before tests
22-
if (await fs.pathExists(TEST_DB_FILE_PATH)) {
23-
await fs.remove(TEST_DB_FILE_PATH);
24-
}
25-
if (await fs.pathExists(TEST_DB_SELECTION_PATH)) {
26-
await fs.remove(TEST_DB_SELECTION_PATH);
21+
// Clean up the entire persistent_data directory for tests
22+
if (await fs.pathExists(PERSISTENT_DATA_PATH)) {
23+
await fs.remove(PERSISTENT_DATA_PATH);
24+
console.log(`[TEST_SETUP_DEBUG] Removed directory: ${PERSISTENT_DATA_PATH}`);
2725
}
2826

29-
// Ensure the database directory exists (it's shared, but files are separate)
27+
// Recreate the necessary directory structure
3028
await fs.ensureDir(path.join(PERSISTENT_DATA_PATH, 'database'));
29+
console.log(`[TEST_SETUP_DEBUG] Ensured directory exists: ${path.join(PERSISTENT_DATA_PATH, 'database')}`);
3130

3231
// IMPORTANT: We need to tell the application to USE this test database file.
3332
// The db/config.ts now uses 'db.selection.test.json' when NODE_ENV is 'test'.

0 commit comments

Comments
 (0)