Search code examples
gruntjsintern

Location of Intern reporters output files like corbertura or html report


I'm using Grunt with Intern and set some reporters to lcovhtml and cobertura:

grunt.initConfig({
        intern: {
            runner: {
                options: {
                    config: 'tests/intern',
                    runType: 'runner',
                    reporters: ['pretty', 'lcovhtml','junit','cobertura']
                }
            }
        },

Is there any configuration to control output directory of these files for all or each reporter?


Solution

  • For example, by adding a parameters reportDir to the options object defined in your Gruntfile.js, you can update intern/lib/reporters/lcovhtml.js with:

    define([
        'dojo/node!istanbul/lib/collector',
        'dojo/node!istanbul/lib/report/html',
        'dojo/node!istanbul/index'
    ], function (Collector, Reporter) {
        var collector = new Collector(),
            reporter = new Reporter();
        //...
    });
    

    with:

    define([
        '../args',
        'dojo/node!istanbul/lib/collector',
        'dojo/node!istanbul/lib/report/html',
        'dojo/node!istanbul/index'
    ], function (args, Collector, Reporter) {
        var collector = new Collector(),
            reporter = new Reporter({ dir: args.reportDir });
        //...
    });
    

    You can propagate a similar update in cobertura.js and junit.js reporters.

    Note: I documented this approach in https://github.com/theintern/intern/issues/71. The patch for the corresponding issue has not yet been published (pushed to Intern 2.3).