webdriverio-community / wdio-html-reporter

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

Fails at execution when no logger is provided #37

Closed rendmath closed 3 years ago

rendmath commented 4 years ago

The reporter always fails at run time when no logger is provider.

reporters: [
    'spec',
    [HtmlReporter, {
        debug: true,
        outputDir: './reports/html-reports/',
        filename: 'report.html',
        reportTitle: 'Test Report Title',
        showInBrowser: true,
        useOnAfterCommandForScreenshot: false,
        //to initialize the logger
        //LOG: log4j.getLogger("default")
    }]
]
[0-0] 2020-08-10T13:21:05.601Z INFO @wdio/local-runner: Run worker command: run
    at new HtmlReporter (C:\sources\training\e2e-training\node_modules\@rpii\wdio-html-reporter\src\reporter.js:34:10)
    at BaseReporter.initReporter (C:\sources\training\e2e-training\node_modules\@wdio\runner\build\reporter.js:116:14)
    at Array.map (<anonymous>)
    at new BaseReporter (C:\sources\training\e2e-training\node_modules\@wdio\runner\build\reporter.js:32:39)
    at Runner.run (C:\sources\training\e2e-training\node_modules\@wdio\runner\build\index.js:74:21)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
[0-0] FAILED
rpii commented 4 years ago

The fix for this is to use the section below to handle the no logger situation. This is in the readme file: I havent seen the need for the fix you provided if this is done as shown below:

To use a logger for debugging

A new feature for developers is to add a log4js logger to see detailed debug output. See the test/reporter.spec.js for configuration options. If you dont want to use the logging, include in your project @log4js-node/log4js-api and you can quiet all debugging. via:

const log4js = require('@log4js-node/log4js-api');
const logger = log4js.getLogger('default');
rendmath commented 4 years ago

Yes, but isn't it an improvement if the reporter works with a minimal configuration without throwing errors, and the additional features can be added incrementally when needed ?

rpii commented 3 years ago

Closing, was implemented