fix(backend-test-utils): prevent suite crash when no databases are available

When eachSupportedId() returned an empty array, describe.each([]) would
throw and crash the entire test suite. Return a placeholder ID instead,
so individual tests fail with a clear error rather than preventing the
entire suite from running.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2026-05-19 23:19:07 +02:00
parent cfb9f07c28
commit 1cbc3241a1
2 changed files with 10 additions and 0 deletions
+3
View File
@@ -108,6 +108,9 @@ export class TestCaches {
}
eachSupportedId(): [TestCacheId][] {
if (this.supportedIds.length === 0) {
return [['MISSING' as TestCacheId]];
}
return this.supportedIds.map(id => [id]);
}
@@ -124,6 +124,13 @@ export class TestDatabases {
}
eachSupportedId(): [TestDatabaseId][] {
if (this.supportedIds.length === 0) {
// Return a placeholder so that describe.each/it.each does not throw
// when no databases are available. The init() call will throw for
// the unknown ID, causing the test to be reported as failed rather
// than crashing the entire suite.
return [['MISSING' as TestDatabaseId]];
}
return this.supportedIds.map(id => [id]);
}