webdriverio-community / wdio-html-reporter

Fork of wdio-html-format-reporter
MIT License
18 stars 28 forks source link

wdio-html-nice-reporter cannot generate aggregated report when there are a lot of suites and cases #91

Open borceacristiann opened 2 years ago

borceacristiann commented 2 years ago

Hello, I am using wdio-html-nice-reporter 8.0.4 and wdio 7.25.0 and found that the master report cannot be generated when there are long(many steps) test suites.

There are 7 test suites, each with its own reports, when aggregating, I got an error in log: Html Generation processing ended in error: RangeError: Invalid string length

I tried to run the specs individually, and for 5 out of 7 the master report was generated, and for the other 2 the error specified above was triggered because they are quite large.

package.json:

{
    "name": "name",
    "version": "1.0.0",
    "devDependencies": {
        "@wdio/cli": "^7.24.0",
        "@wdio/local-runner": "^7.24.0",
        "@wdio/mocha-framework": "^7.24.0",
        "@wdio/spec-reporter": "^7.24.0",
        "chromedriver": "^106.0.0",
        "log4js": "^6.5.2",
        "wdio-chromedriver-service": "^7.3.2",
        "wdio-html-nice-reporter": "8.0.4",
        "wdio-ui5-service": "^0.9.10"
    }
}

wdio..conf.js:

const { ReportAggregator } = require('wdio-html-nice-reporter');
const LOG = require('log4js');

const { urls } = require('./utils/constants');

LOG.configure({
    appenders: {
        fileLog: {
            type: 'file',
            filename: "logs/html-reporter.log",
            maxLogSize: 5000000,
            level: 'debug'
        },
        debugLog: {
            type: 'file',
            filename: "logs/debug-html-reporter.log",
            maxLogSize: 5000000,
            level: 'debug'
        },
        'out': {
            type: 'stdout',
            layout: {
                type: "colored"
            }
        },
        'filterOut': {
            type: 'stdout',
            layout: {
                type: "colored"
            },
            level: 'info'
        }
    },
    categories: {
        file: { appenders: ['fileLog'], level: 'info' },
        default: { appenders: ['out', 'fileLog'], level: 'info' },
        console: { appenders: ['out'], level: 'info' },
        debug: { appenders: ['debugLog'], level: 'debug' }
    }
});

let logger = LOG.getLogger("default");

let reportAggregator;

exports.config = {
    wdi5: {
        screenshotPath: "./reports/html-reports/screenshots",
        screenshotsDisabled: false, // [optional] {boolean}, default: false; if set to true, screenshots won't be taken and not written to file system
        logLevel: "error", // [optional] error | verbose | silent, default: "error"
        url: "", // [mandatory] {string} name of your bootstrap html file. If your server autoredirects to a 'domain:port/'-like root url, use empty string ''
        skipInjectUI5OnStart: true, // [optional] {boolean}, default: false; true when UI5 is not on the start page, you need to later call <wdioUI5service>.injectUI5() manually
        waitForUI5Timeout: 15000 // [optional] {number}, default: 15000; maximum waiting time in milliseconds while checking for UI5 availability
    },
    framework: 'mocha',
    reporters: ['spec',
        ["html-nice", {
            outputDir: './reports/html-reports/',
            filename: 'report.html',
            reportTitle: 'Test Report Title',
            linkScreenshots: true,
            //to show the report in a browser when done
            showInBrowser: true,
            collapseTests: true,
            //to turn on screenshots after every test
            useOnAfterCommandForScreenshot: true,
            LOG: logger
        }
        ]
    ],
    mochaOpts: {
        ui: 'bdd',
        timeout: 100000
    },
    onPrepare: function (config, capabilities) {
        reportAggregator = new ReportAggregator({
            outputDir: './reports/html-reports/',
            filename: 'master-report.html',
            reportTitle: 'Master Report',
            browserName: capabilities.browserName,
            collapseTests: true,
            // LOG: logger
        });
        reportAggregator.clean();
    },
    onComplete: function (exitCode, config, capabilities, results) {
        (async () => {
            await reportAggregator.createReport();
        })();
    }
}
borceacristiann commented 2 years ago

Hello, do you have any news related to this issue?