Skip to content

Test Infra: Always fail afterEach if expected errors don't match logged errors, even if the test isn't otherwise passing. #21803

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import type {
SharedString,
} from "@fluidframework/sequence/internal";
import { SharedObject } from "@fluidframework/shared-object-base/internal";
import { GenericError } from "@fluidframework/telemetry-utils/internal";
import {
ChannelFactoryRegistry,
createSummarizer,
Expand Down Expand Up @@ -344,6 +345,12 @@ describeCompat("stashed ops", "NoCompat", (getTestObjectProvider, apis) => {
string1.insertText(0, "hello");
});

//* TEMP - DO NOT MERGE
it("testing double failure reporting", () => {
container1.close(new GenericError("Cause an error to be logged (will fail the 'afterEach' block)"));
assert.fail("Cause the test itself to fail");
});

it("resends op", async function () {
const pendingOps = await getPendingOps(
testContainerConfig,
Expand Down
12 changes: 4 additions & 8 deletions packages/test/test-version-utils/src/describeCompat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,12 @@ function createCompatSuite(
return provider;
}, apis);

// eslint-disable-next-line prefer-arrow-callback
afterEach(function (done: Mocha.Done) {
const logErrors = getUnexpectedLogErrorException(provider.tracker);
// if the test failed for another reason
// then we don't need to check errors
// and fail the after each as well
if (this.currentTest?.state === "passed") {
done(logErrors);
} else {
done();
}
// Note: This will add a failure in "afterEach" to the results, which may appear redundant if the test itself failed
// However, this extra information may be useful to diagnose the root cause of the failure.
done(logErrors);
if (resetAfterEach) {
provider.reset();
}
Expand Down
Loading