diff --git a/CHANGELOG.md b/CHANGELOG.md index 839dc97baa4e..199f1c401e2d 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 and @cjreimer for highlighting this! + - fix(serve): Allow periods in most paths (#10114) Partial fix for route paths with periods in them. 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 }) }