Don't ignore errors in the Jasmine suite start/end stages

Currently errors in `afterAll` are logged, but don't fail the tests.
This could cause new errors during test teardown to go by unnoticed.

Moreover, the integration test use a different reporting mechanism which
also handled errors differently (this is extra reason to do #12730).

This patch fixes the issues by consistently handling errors in
`suiteStarted` and `suiteDone` in both reporting mechanisms.

Fixes #18319.
This commit is contained in:
Tim van der Meij 2024-06-23 19:56:37 +02:00
parent 6784124a74
commit 2f3bf6f07e
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
2 changed files with 27 additions and 9 deletions

View file

@ -44,6 +44,7 @@ async function runTests(results) {
jasmineDone(suiteInfo) {},
jasmineStarted(suiteInfo) {},
specDone(result) {
// Report on the result of individual tests.
++results.runs;
if (result.failedExpectations.length > 0) {
++results.failures;
@ -53,8 +54,20 @@ async function runTests(results) {
}
},
specStarted(result) {},
suiteDone(result) {},
suiteStarted(result) {},
suiteDone(result) {
// Report on the result of `afterAll` invocations.
if (result.failedExpectations.length > 0) {
++results.failures;
console.log(`TEST-UNEXPECTED-FAIL | ${result.description}`);
}
},
suiteStarted(result) {
// Report on the result of `beforeAll` invocations.
if (result.failedExpectations.length > 0) {
++results.failures;
console.log(`TEST-UNEXPECTED-FAIL | ${result.description}`);
}
},
});
return jasmine.execute();