microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.68k stars 3.65k forks source link

[Feature] advanced inbuild html report #19360

Closed k87perera closed 6 months ago

k87perera commented 1 year ago

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

cenfun commented 1 year ago

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);
                }
            }
        }]
    ]
};
mm0hammadi commented 1 year ago

Awsome :+1:

anbhattacharjee commented 1 year ago

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 ?

pavelfeldman commented 6 months ago

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.

Az8th commented 3 months ago

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