asciidisco / grunt-qunit-istanbul

Run QUnit unit tests in a headless PhantomJS instance & generate some nice code coverage metrics using Istanbul.
MIT License
33 stars 21 forks source link

[regression] instrumentedFiles -> temp folder not created properly resulting in error every other run #62

Open tyge68 opened 7 years ago

tyge68 commented 7 years ago

I have a odd issue since using version 1.0.0 of this plugin.

Now each time I execute the qunit task configured as follow:

   qunit: {
        options: {
          '--web-security': 'no',
          coverage: {
            disposeCollector: true,
            src: ['src/**/*.js'],
            instrumentedFiles: 'temp/',
            jsonSummaryReport: 'report/json',
            htmlReport: 'report/coverage',
            lcovReport: 'report/',
            excludes: ['libs/*'],
            linesThresholdPct: 80
          }
        },
        all: ['testing/index.html']
    }

It fails every other run, from the investigation , it never fail if I make sure that the instrumentedFiles ("temp/") folder is created before executing. Which explain why it fails every other run then, as when it fails, the "temp/" folder is not removed, so the next run passes.

agistrilink commented 7 years ago

A workaround can be to alter the code in the tasks/qunit.js:241 by wrapping the options.coverage.instrumentedFiles to fs.realpathSync(options.coverage.instrumentedFiles).

The other, preferable workaround (no code change!) is to specify an absolute and portable path, e.g. /tmp.

fabschen commented 7 years ago

@agistrilink I link the workaround here.