cenfun / monocart-reporter

A playwright test reporter (Node.js)
https://cenfun.github.io/monocart-reporter/
MIT License
194 stars 11 forks source link

github summary #120

Closed BrunoCD closed 3 months ago

BrunoCD commented 3 months ago

Is there a way to print the output of the summary to github so it can be seen at the end of the run?

cenfun commented 3 months ago

It should print the summary to github by default. image see https://github.com/cenfun/monocart-reporter/actions/runs/9231893508/job/25402398312 And also you can print anything you want with onEnd hook

// playwright.config.js
module.exports = {
    reporter: [
        ['monocart-reporter', {  
            name: "My Test Report",
            outputFile: './test-results/report.html',
            // async hook after report data generated
            onEnd: async (reportData, helper) => {
                console.log(reportData.summary);

                // find a test by title
                const myCase = helper.find((item, parent) => item.type === 'case' && item.title.includes('inline tag'));
                console.log(myCase && myCase.title);

                // find a suite by title
                const mySuite = helper.find((item, parent) => item.type === 'suite' && item.title.includes('new syntax'));
                console.log(mySuite && mySuite.title);

                // filter failed cases
                const failedCases = helper.filter((item, parent) => item.type === 'case' && item.caseType === 'failed');
                console.log(failedCases.map((it) => it.title));

                // Iterate all items
                helper.forEach((item, parent) => {
                    // do something
                });

            }
        }]
    ]
};
BrunoCD commented 3 months ago

I understand that this is part of the run. Since, I am sharding the tests: npx playwright test --shard=1/4, etc I want the output to show up in the SUMMARY page of github with the total number of tests instead of the individual shards Let's say if shards have 20 tests per, and I have 4 shards, I want to see: Playwright Results image

Is this possible ? How?

cenfun commented 3 months ago

Yes, of course. see Merge Shard Reports