Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scenario): Make sure to cleanup even if test fails #10112

Merged
merged 4 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading