Skip to content

Commit

Permalink
feat(allure-playwright): support skip and fixme annotations (voa allu…
Browse files Browse the repository at this point in the history
  • Loading branch information
baev authored Jul 2, 2024
1 parent e7b8aea commit 54d0087
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/allure-playwright/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,13 @@ export class AllureReporter implements ReporterV2 {

if (error) {
testResult.statusDetails = { ...getMessageAndTraceFromError(error) };
} else {
const skipReason = test.annotations?.find(
(annotation) => annotation.type === "skip" || annotation.type === "fixme",
)?.description;
if (skipReason) {
testResult.statusDetails = { ...testResult.statusDetails, message: skipReason };
}
}

testResult.status = statusToAllureStats(result.status, test.expectedStatus);
Expand Down
58 changes: 58 additions & 0 deletions packages/allure-playwright/test/spec/annotations.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { expect, it } from "vitest";
import { runPlaywrightInlineTest } from "../utils.js";

it("should support skip annotation", async () => {
const { tests } = await runPlaywrightInlineTest({
"sample.test.js": `
import { test } from '@playwright/test';
test('test full report', {
annotation: {
type: "skip",
description: "skipped via skip annotation",
},
}, async () => {
});
`,
});

expect(tests).toEqual(
expect.arrayContaining([
expect.objectContaining({
name: "test full report",
status: "skipped",
statusDetails: expect.objectContaining({
message: "skipped via skip annotation",
}),
}),
]),
);
});

it("should support fixme annotation", async () => {
const { tests } = await runPlaywrightInlineTest({
"sample.test.js": `
import { test } from '@playwright/test';
test('test full report', {
annotation: {
type: "fixme",
description: "skipped via fixme annotation",
},
}, async () => {
});
`,
});

expect(tests).toEqual(
expect.arrayContaining([
expect.objectContaining({
name: "test full report",
status: "skipped",
statusDetails: expect.objectContaining({
message: "skipped via fixme annotation",
}),
}),
]),
);
});
11 changes: 11 additions & 0 deletions packages/allure-playwright/test/spec/skip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ it("reports programmatically skipped results", async () => {
test.skip('should be skipped 1', async () => {});
test('should not be skipped', async () => {});
test('should be skipped 2', async () => {
test.skip(true, "runtime skip");
});
`,
});

Expand All @@ -21,6 +25,13 @@ it("reports programmatically skipped results", async () => {
status: Status.SKIPPED,
testCaseId: md5("sample.test.js#should be skipped 1"),
}),
expect.objectContaining({
status: Status.SKIPPED,
testCaseId: md5("sample.test.js#should be skipped 2"),
statusDetails: expect.objectContaining({
message: "runtime skip",
}),
}),
expect.objectContaining({
fullName: "sample.test.js:6:11",
status: Status.PASSED,
Expand Down

0 comments on commit 54d0087

Please sign in to comment.