Skip to content
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
8 changes: 4 additions & 4 deletions packages/plugin-classic/src/categories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export const matchCategories = (

const categoryMatch = (
category: ClassicCategory,
result: { statusMessage?: string; statusTrace?: string; status: TestStatus; flaky: boolean },
result: { message?: string; trace?: string; status: TestStatus; flaky: boolean },
): boolean => {
const { status, statusMessage, statusTrace, flaky } = result;
const { status, message, trace, flaky } = result;
const matchesStatus =
!category.matchedStatuses || category.matchedStatuses.length === 0 || category.matchedStatuses.includes(status);
const matchesMessage = match(category.messageRegex, statusMessage);
const matchesTrace = match(category.traceRegex, statusTrace);
const matchesMessage = match(category.messageRegex, message);
const matchesTrace = match(category.traceRegex, trace);
const matchesFlaky = (category.flaky ?? flaky) === flaky;
return matchesStatus && matchesMessage && matchesTrace && matchesFlaky;
};
Expand Down
18 changes: 14 additions & 4 deletions packages/plugin-classic/test/categories.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("categories", () => {
],
{
status: "failed",
statusMessage: "hello here the result with some message and more",
message: "hello here the result with some message and more",
flaky: false,
},
);
Expand All @@ -56,7 +56,7 @@ describe("categories", () => {
],
{
status: "failed",
statusMessage: "hello\n here the result\nwith some message and\nmore\n",
message: "hello\n here the result\nwith some message and\nmore\n",
flaky: false,
},
);
Expand All @@ -74,7 +74,7 @@ describe("categories", () => {
],
{
status: "failed",
statusTrace: "hello here the result with some message and more",
trace: "hello here the result with some message and more",
flaky: false,
},
);
Expand All @@ -92,12 +92,22 @@ describe("categories", () => {
],
{
status: "failed",
statusTrace: "hello\n here the result\nwith some message and\nmore\n",
trace: "hello\n here the result\nwith some message and\nmore\n",
flaky: false,
},
);
expect(matched).to.have.lengthOf(2, "should match provided category");
expect(matched[0]).to.have.property("name", "some message category");
expect(matched[1]).to.have.property("name", "all matched category");
});
it("should match by message using the generators.ts call shape (regression)", () => {
const matched = matchCategories([{ name: "network failure category", messageRegex: ".*connection refused.*" }], {
message: "Error: connect ECONNREFUSED 127.0.0.1:8080 (connection refused)",
trace: "at Object.connect (net.js:100:10)",
status: "failed",
flaky: false,
});
expect(matched).to.have.lengthOf(1, "should match category by messageRegex");
expect(matched[0]).to.have.property("name", "network failure category");
});
});