Closed aakashgupt closed 7 months ago
hi @aakashgupt
You can use a custom layout to achieve this.
playwright.config.ts
import { defineConfig } from "@playwright/test";
import generateCustomLayout from "./custom_layout";
export default defineConfig({
testDir: "./tests",
reporter: [
[
"./node_modules/playwright-slack-report/dist/src/SlackReporter.js",
{
channels: ["pw"],
sendResults: "always",
layout: generateCustomLayout,
slackLogLevel: "INFO",
disableUnfurl: false,
showInThread: false,
},
],
],
});
Place this file in the root of your project ...
custom_layout.ts
import { Block, KnownBlock } from "@slack/types";
type SummaryResults = {
passed: number;
failed: number;
flaky: number | undefined;
skipped: number;
failures: Array<{
suite: string;
test: string;
failureReason: string;
}>;
meta?: Array<{ key: string; value: string }>;
tests: Array<{
suiteName: string;
name: string;
browser?: string;
projectName?: string;
endedAt: string;
reason: string;
retry: number;
startedAt: string;
status: "passed" | "failed" | "timedOut" | "skipped";
attachments?: {
body: string | undefined | Buffer;
contentType: string;
name: string;
path: string;
}[];
}>;
};
export default function generateCustomLayout(
summaryResults: SummaryResults
): Array<Block | KnownBlock> {
return [
{
type: "section",
text: {
type: "mrkdwn",
text: "🎭 *Playwright Results*",
},
},
{
type: "section",
text: {
type: "mrkdwn",
text: `✅ *${
summaryResults.flaky
? summaryResults.flaky + summaryResults.passed
: summaryResults.passed
}* | ❌ *${summaryResults.failed}* `,
},
},
];
}
I am closing this question, i haven't used your solution though. just stuck with some work
Hi,
I want to achieve the following with Slack notification:
Context: