Skip to content

Commit

Permalink
Merge pull request #178 from lloydcotten/master
Browse files Browse the repository at this point in the history
Include extra extensions in glob for --all switch
  • Loading branch information
bcoe committed Mar 2, 2016
2 parents af58d86 + 4323b7f commit b5907ad
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/not-loaded.es6
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
var i = 3 + 5
i++
27 changes: 27 additions & 0 deletions test/src/nyc-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b5907ad

Please sign in to comment.