Skip to content

Commit

Permalink
fix(scenario): Make sure to cleanup even if test fails (#10112)
Browse files Browse the repository at this point in the history
  • Loading branch information
dac09 committed Mar 6, 2024
1 parent a1ce67b commit e9ecbb0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 8 additions & 5 deletions packages/testing/config/jest/api/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
}

Expand Down

0 comments on commit e9ecbb0

Please sign in to comment.