1

I have setting up a configuration in 'wdio.conf.js' for "rpii html reporter". But its not generating master report for all suites.

const { ReportAggregator, HtmlReporter } = require('@rpii/wdio-html-reporter');
exports.config = {

    reporters: ['spec', [HtmlReporter, {
        debug: true,
        outputDir: './reports/html-reports/',
        filename: 'report.html',
        reportTitle: 'Test Report Title',
        showInBrowser:true
    }
    ]],

    onPrepare: function (config, capabilities) {

        let reportAggregator = new ReportAggregator({
            outputDir: './reports/html-reports/',
            filename: 'master-report.html',
            reportTitle: 'Master Report'
        });
        reportAggregator.clean() ;

        global.reportAggregator = reportAggregator;
    },

    onComplete: function(exitCode, config, capabilities, results) {
        (async () => {
            await global.reportAggregator.createReport( {
                config: config,
                capabilities: capabilities,
                results : results
            });
        })();
    }
}

I expect single report with multiple test cases. But I'm getting multiple reports for each test cases.

vinil narayan
  • 31
  • 1
  • 5

2 Answers2

3

The topic is pretty old atm, but I just addressed a similar issue in my project - cannot generate the report at all. In most of the case, it is just a matter of configuration, but there is no solid document or guideline for this painful wdio reporter configuration. So here I am, after a whole week of research and testing around, these are viable config you will need and other fellows out there who is/was facing the same issue.

First, let assume your project structure would be something like the below tree

.
├── some_folder1
│   ├── some_sub_folder1
│   ├── some_sub_folder2
├── some_folder2
├── @report
│   ├── html-reports
│   ├── template
│   │   ├── sanity-mobile-report-template.hbs
│   │   ├── wdio-html-template.hbs
├── specs
│   ├── test1
│   │   ├── test1.doSuccess.spec.js
│   │   ├── test1.doFail.spec.js
│   ├── test2
│   │   ├── test2.doSuccess.spec.js
│   │   ├── test2.doFail.spec.js
├── node-modules
├── package.json

Second, you should have templates for your reports, in my case, it is located in @report/template wdio-html-template.hbs and sanity-mobile-report-template.hbs for HtmlReporter and ReportAggregator respectively. As Rich Peters has notices above

Each suite is executed individually and an html and json file are generated. wdio does not aggregate the suites, so this is done by the report aggregator collecting all the files and creating an aggregate file when complete

The HtmlReporter will actually need to find it template for generating the content for each .spec file, then there is a need for another template requested by ReportAggregator

enter image description here

Third, you need correct specs and suites declaration in your wdio config, generic for specs, and file specifically for suites. enter image description here

Final, run your test using --suite parameter, reference to wdio guideline

My final project structure would look like this, notice the changes

.
├── some_folder1
│   ├── some_sub_folder1
│   ├── some_sub_folder2
├── some_folder2
├── @report
│   ├── html-reports
│   ├── ├── screenshots
│   ├── ├── suite-0-0
│   ├── ├── ├── 0-0
│   ├── ├── ├── ├── report.html
│   ├── ├── ├── ├── report.json
│   ├── ├── ├── 0-1
│   ├── ├── ├── ├── report.html
│   ├── ├── ├── ├── report.json
│   ├── ├── master-report.html
│   ├── ├── master-report.json
│   ├── template
│   │   ├── sanity-mobile-report-template.hbs
│   │   ├── wdio-html-template.hbs
├── specs
│   ├── test1
│   │   ├── test1.doSuccess.spec.js
│   │   ├── test1.doFail.spec.js
│   ├── test2
│   │   ├── test2.doSuccess.spec.js
│   │   ├── test2.doFail.spec.js
├── node-modules
├── package.json
Nidust
  • 541
  • 1
  • 7
  • 15
0

Each suite is executed individually and an html and json file are generated. wdio does not aggregate the suites, so this is done by the report aggregator collecting all the files and creating an aggregate file when complete.