diff --git a/index.js b/index.js index 456aeba6e..0b0a36d55 100755 --- a/index.js +++ b/index.js @@ -196,7 +196,8 @@ NYC.prototype.addAllFiles = function () { this._loadAdditionalModules() - glob.sync('**/*.js', {cwd: this.cwd, nodir: true, ignore: this.exclude}).forEach(function (filename) { + var pattern = '**/*{' + this.extensions.join() + '}' + glob.sync(pattern, {cwd: this.cwd, nodir: true, ignore: this.exclude}).forEach(function (filename) { var obj = _this.addFile(path.join(_this.cwd, filename)) if (obj.instrument) { module._compile( diff --git a/test/fixtures/not-loaded.es6 b/test/fixtures/not-loaded.es6 new file mode 100644 index 000000000..d1db34ee3 --- /dev/null +++ b/test/fixtures/not-loaded.es6 @@ -0,0 +1,2 @@ +var i = 3 + 5 +i++ diff --git a/test/src/nyc-test.js b/test/src/nyc-test.js index 4fa266d70..d17df1827 100644 --- a/test/src/nyc-test.js +++ b/test/src/nyc-test.js @@ -546,6 +546,33 @@ describe('nyc', function () { return done() }) + it('outputs an empty coverage report for multiple configured extensions', function (done) { + var nyc = new NYC({ + cwd: fixtures + }) + nyc.reset() + nyc.addAllFiles() + + var notLoadedPath1 = path.join(fixtures, './not-loaded.es6') + var notLoadedPath2 = path.join(fixtures, './not-loaded.js') + var reports = _.filter(nyc._loadReports(), function (report) { + var apr = ap(report) + return apr[notLoadedPath1] || apr[notLoadedPath2] + }) + + reports.length.should.equal(1) + + var report1 = reports[0][notLoadedPath1] + report1.s['1'].should.equal(0) + report1.s['2'].should.equal(0) + + var report2 = reports[0][notLoadedPath2] + report2.s['1'].should.equal(0) + report2.s['2'].should.equal(0) + + return done() + }) + it('tracks coverage appropriately once the file is required', function (done) { var nyc = (new NYC({ cwd: fixtures