playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Feature] advanced inbuild html report

Open k87perera opened this issue 2 years ago • 2 comments

can you add more features to html reporter in playwright. eg: allure report over view page. and send report as a email functionality. Most of top management like to see consolidate report. allure report is good but it is not a inbuild report due to that we need face data sync issues most of the time

k87perera avatar Dec 08 '22 14:12 k87perera

try this custom reporter:

// playwright.config.js
module.exports = {
    reporter: [
        ['monocart-reporter', {  
            name: "My Test Report",
            outputFile: './test-results/report.html',

            onEnd: async (reportData, { sendEmail, config }) => {
                const emailOptions = {
                    // https://nodemailer.com/smtp/
                    transport: {
                        service: 'Hotmail',
                        auth: {
                            user: '',
                            pass: ''
                        }
                    },
                    // https://nodemailer.com/message/
                    message: {
                        from: '',
                        to: '',
                        cc: '',
                        bcc: '',

                        subject: `${reportData.name} - ${reportData.dateH}`,
                        attachments: [{
                            path: reportData.htmlPath
                        }],

                        html: `
                            <h3>${reportData.name}</h3>
                            <ul>
                                <li>Env: STG</li>
                                <li>Type: Smoke</li>
                                <li>Url: ${reportData.use.url}</li>
                                <li>Workers: ${config.workers}</li>
                                <li>Date: ${reportData.dateH}</li>
                                <li>Duration: ${reportData.durationH}</li>
                            </ul>
                            
                            ${reportData.summaryTable}

                            <p>Please check attachment html for detail.</p>

                            <p>Thanks,</p>
                        `
                    }
                };

                const info = await sendEmail(emailOptions).catch((e) => {
                    console.error(e);
                });
                if (info) {
                    console.log(info);
                }
            }
        }]
    ]
};

cenfun avatar Mar 02 '23 08:03 cenfun

Awsome :+1:

mm0hammadi avatar May 08 '23 12:05 mm0hammadi

Can we add this on CustomReporter.onEnd method with a zip file as attachment ? Also is it possible to send the same with HTML report, instead of monocart-reporter ?

anbhattacharjee avatar Aug 17 '23 18:08 anbhattacharjee

Why was this issue closed?

Thank you for your involvement. This issue was closed due to limited engagement (upvotes/activity), lack of recent activity, and insufficient actionability. To maintain a manageable database, we prioritize issues based on these factors.

If you disagree with this closure, please open a new issue and reference this one. More support or clarity on its necessity may prompt a review. Your understanding and cooperation are appreciated.

pavelfeldman avatar Apr 22 '24 17:04 pavelfeldman

@k87perera You should consider using https://github.com/estruyf/playwright-mail-reporter ;)

Az8th avatar Aug 04 '24 17:08 Az8th