From 1cbc3241a1e9091840fb4c7f22cf28493c60a468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 19 May 2026 23:19:07 +0200 Subject: [PATCH 1/4] fix(backend-test-utils): prevent suite crash when no databases are available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) Signed-off-by: Fredrik Adelöw --- packages/backend-test-utils/src/cache/TestCaches.ts | 3 +++ packages/backend-test-utils/src/database/TestDatabases.ts | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/packages/backend-test-utils/src/cache/TestCaches.ts b/packages/backend-test-utils/src/cache/TestCaches.ts index d4553697bf..27c07daa32 100644 --- a/packages/backend-test-utils/src/cache/TestCaches.ts +++ b/packages/backend-test-utils/src/cache/TestCaches.ts @@ -108,6 +108,9 @@ export class TestCaches { } eachSupportedId(): [TestCacheId][] { + if (this.supportedIds.length === 0) { + return [['MISSING' as TestCacheId]]; + } return this.supportedIds.map(id => [id]); } diff --git a/packages/backend-test-utils/src/database/TestDatabases.ts b/packages/backend-test-utils/src/database/TestDatabases.ts index 8baac04193..46d966b6ee 100644 --- a/packages/backend-test-utils/src/database/TestDatabases.ts +++ b/packages/backend-test-utils/src/database/TestDatabases.ts @@ -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]); } From 03f0f3f953bb844d6745322c29dafffc095863d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 19 May 2026 23:19:18 +0200 Subject: [PATCH 2/4] Add changeset MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Fredrik Adelöw --- .changeset/fix-empty-each-tests.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fix-empty-each-tests.md diff --git a/.changeset/fix-empty-each-tests.md b/.changeset/fix-empty-each-tests.md new file mode 100644 index 0000000000..71cc06c30d --- /dev/null +++ b/.changeset/fix-empty-each-tests.md @@ -0,0 +1,5 @@ +--- +'@backstage/backend-test-utils': patch +--- + +Fixed a crash in test suites that use `TestDatabases` or `TestCaches` when none of the requested database or cache engines are available. Previously, `eachSupportedId()` would return an empty array causing `describe.each` to throw and prevent the entire suite from running. Now returns a placeholder entry so individual tests report a clear failure instead. From 2c53691962ee8c21fade285b65d359457a938c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 19 May 2026 23:21:47 +0200 Subject: [PATCH 3/4] Fix postgres env var casing in deploy_packages workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The env vars used lowercase postgres18/postgres14 instead of uppercase POSTGRES18/POSTGRES14, which didn't match the names expected by TestDatabases. This caused all postgres-only test suites to see no available databases and crash. Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Fredrik Adelöw --- .github/workflows/deploy_packages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy_packages.yml b/.github/workflows/deploy_packages.yml index b7791d522e..af0892d8a5 100644 --- a/.github/workflows/deploy_packages.yml +++ b/.github/workflows/deploy_packages.yml @@ -118,8 +118,8 @@ jobs: yarn backstage-cli repo test --maxWorkers=3 --workerIdleMemoryLimit=1300M --coverage --success-cache --success-cache-dir .cache/backstage-cli env: BACKSTAGE_TEST_DISABLE_DOCKER: 1 - BACKSTAGE_TEST_DATABASE_postgres18_CONNECTION_STRING: postgresql://postgres:postgres@localhost:${{ job.services.postgres18.ports[5432] }} - BACKSTAGE_TEST_DATABASE_postgres14_CONNECTION_STRING: postgresql://postgres:postgres@localhost:${{ job.services.postgres14.ports[5432] }} + BACKSTAGE_TEST_DATABASE_POSTGRES18_CONNECTION_STRING: postgresql://postgres:postgres@localhost:${{ job.services.postgres18.ports[5432] }} + BACKSTAGE_TEST_DATABASE_POSTGRES14_CONNECTION_STRING: postgresql://postgres:postgres@localhost:${{ job.services.postgres14.ports[5432] }} BACKSTAGE_TEST_DATABASE_MYSQL8_CONNECTION_STRING: mysql://root:root@localhost:${{ job.services.mysql8.ports[3306] }}/ignored BACKSTAGE_TEST_CACHE_REDIS7_CONNECTION_STRING: redis://localhost:${{ job.services.redis.ports[6379] }} From 8abfa78e4cfdf49f9bb7fa9dc5a8387fa1d55383 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Tue, 19 May 2026 23:23:37 +0200 Subject: [PATCH 4/4] =?UTF-8?q?Revert=20eachSupportedId=20guard=20?= =?UTF-8?q?=E2=80=94=20env=20var=20fix=20is=20sufficient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Fredrik Adelöw --- .changeset/fix-empty-each-tests.md | 5 ----- packages/backend-test-utils/src/cache/TestCaches.ts | 3 --- packages/backend-test-utils/src/database/TestDatabases.ts | 7 ------- 3 files changed, 15 deletions(-) delete mode 100644 .changeset/fix-empty-each-tests.md diff --git a/.changeset/fix-empty-each-tests.md b/.changeset/fix-empty-each-tests.md deleted file mode 100644 index 71cc06c30d..0000000000 --- a/.changeset/fix-empty-each-tests.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@backstage/backend-test-utils': patch ---- - -Fixed a crash in test suites that use `TestDatabases` or `TestCaches` when none of the requested database or cache engines are available. Previously, `eachSupportedId()` would return an empty array causing `describe.each` to throw and prevent the entire suite from running. Now returns a placeholder entry so individual tests report a clear failure instead. diff --git a/packages/backend-test-utils/src/cache/TestCaches.ts b/packages/backend-test-utils/src/cache/TestCaches.ts index 27c07daa32..d4553697bf 100644 --- a/packages/backend-test-utils/src/cache/TestCaches.ts +++ b/packages/backend-test-utils/src/cache/TestCaches.ts @@ -108,9 +108,6 @@ export class TestCaches { } eachSupportedId(): [TestCacheId][] { - if (this.supportedIds.length === 0) { - return [['MISSING' as TestCacheId]]; - } return this.supportedIds.map(id => [id]); } diff --git a/packages/backend-test-utils/src/database/TestDatabases.ts b/packages/backend-test-utils/src/database/TestDatabases.ts index 46d966b6ee..8baac04193 100644 --- a/packages/backend-test-utils/src/database/TestDatabases.ts +++ b/packages/backend-test-utils/src/database/TestDatabases.ts @@ -124,13 +124,6 @@ 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]); }