From 046a3c8901c3592841c14dd7ea2d473fb376c412 Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Tue, 5 Mar 2024 13:19:35 +0700 Subject: [PATCH 1/3] fix(scenario): Make sure to cleanup even if test fails --- packages/testing/config/jest/api/jest.setup.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/testing/config/jest/api/jest.setup.js b/packages/testing/config/jest/api/jest.setup.js index b962ff9ea476..2c6fba2a1ae0 100644 --- a/packages/testing/config/jest/api/jest.setup.js +++ b/packages/testing/config/jest/api/jest.setup.js @@ -104,13 +104,16 @@ const buildScenario = let { scenario } = loadScenarios(testPath, scenarioName) const scenarioData = await seedScenario(scenario) - const result = await testFunc(scenarioData) + try { + const result = await testFunc(scenarioData) - if (wasDbUsed()) { - await teardown() + return result + } finally { + // Make sure to cleanup, even if test fails + if (wasDbUsed()) { + await teardown() + } } - - return result }) } From 377e9a9355a3c8d9e01683570f2ecdd1a014cb2f Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Tue, 5 Mar 2024 16:49:50 +0700 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a20a32767ec..d124d2f58ade 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +- fix(scenario): Make sure to clean up scenarios even if tests fail (#10112) + Fixes an issue where a unit test failure would cause the scenario cleanup to be skipped. Thanks @peraltafederico for highlighting this! + - fix(deps): update prisma monorepo to v5.10.2 (#10088) This release updates Prisma to v5.10.2. Here are quick links to all the release notes since the last version (v5.9.1): From 5826e4f28405a12728df09080898696346fafa8d Mon Sep 17 00:00:00 2001 From: Daniel Choudhury Date: Tue, 5 Mar 2024 17:05:02 +0700 Subject: [PATCH 3/3] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d124d2f58ade..42c925a35aa4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased - fix(scenario): Make sure to clean up scenarios even if tests fail (#10112) - Fixes an issue where a unit test failure would cause the scenario cleanup to be skipped. Thanks @peraltafederico for highlighting this! + Fixes an issue where a unit test failure would cause the scenario cleanup to be skipped. Thanks @peraltafederico and @cjreimer for highlighting this! - fix(deps): update prisma monorepo to v5.10.2 (#10088)