From b25c8c9bdf8bbed1316feb6cf61727b293476a89 Mon Sep 17 00:00:00 2001 From: Lloyd Cotten Date: Mon, 29 Feb 2016 23:48:58 -0330 Subject: [PATCH 1/2] Include extra extensions in glob for --all switch --- index.js | 3 ++- test/fixtures/not-loaded.es6 | 2 ++ test/src/nyc-test.js | 18 +++++++++++++----- 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 test/fixtures/not-loaded.es6 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..abb370266 100644 --- a/test/src/nyc-test.js +++ b/test/src/nyc-test.js @@ -534,15 +534,23 @@ describe('nyc', function () { nyc.reset() nyc.addAllFiles() - var notLoadedPath = path.join(fixtures, './not-loaded.js') + var notLoadedPath1 = path.join(fixtures, './not-loaded.es6') + var notLoadedPath2 = path.join(fixtures, './not-loaded.js') var reports = _.filter(nyc._loadReports(), function (report) { - return ap(report)[notLoadedPath] + var apr = ap(report) + return apr[notLoadedPath1] || apr[notLoadedPath2] }) - var report = reports[0][notLoadedPath] reports.length.should.equal(1) - report.s['1'].should.equal(0) - report.s['2'].should.equal(0) + + 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() }) From 4323b7f48252f8d7e5984c42f0e27c70c187b7ae Mon Sep 17 00:00:00 2001 From: Lloyd Cotten Date: Wed, 2 Mar 2016 00:23:44 -0330 Subject: [PATCH 2/2] Separate tests --- test/src/nyc-test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/src/nyc-test.js b/test/src/nyc-test.js index abb370266..d17df1827 100644 --- a/test/src/nyc-test.js +++ b/test/src/nyc-test.js @@ -534,6 +534,25 @@ describe('nyc', function () { nyc.reset() nyc.addAllFiles() + var notLoadedPath = path.join(fixtures, './not-loaded.js') + var reports = _.filter(nyc._loadReports(), function (report) { + return ap(report)[notLoadedPath] + }) + var report = reports[0][notLoadedPath] + + reports.length.should.equal(1) + report.s['1'].should.equal(0) + report.s['2'].should.equal(0) + 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) {