-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow exclude/include options to be passed as Babel plugin conf…
…ig (#16)
- Loading branch information
Showing
5 changed files
with
69 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let foo = function () { | ||
console.log('foo') | ||
} | ||
foo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let bar = function () { | ||
console.log('bar') | ||
} | ||
bar() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,52 @@ | ||
/* global describe, it */ | ||
/* global context, describe, it */ | ||
|
||
const babel = require('babel-core') | ||
import makeVisitor from '../src' | ||
|
||
require('chai').should() | ||
|
||
describe('babel-plugin-istanbul', function () { | ||
it('should instrument file if shouldSkip returns false', function () { | ||
var result = babel.transformFileSync('./fixtures/should-cover.js', { | ||
plugins: [ | ||
makeVisitor({types: babel.types}) | ||
] | ||
context('Babel plugin config', function () { | ||
it('should instrument file if shouldSkip returns false', function () { | ||
var result = babel.transformFileSync('./fixtures/plugin-should-cover.js', { | ||
plugins: [ | ||
[makeVisitor({types: babel.types}), { | ||
include: ['fixtures/plugin-should-cover.js'] | ||
}] | ||
] | ||
}) | ||
result.code.should.match(/statementMap/) | ||
}) | ||
|
||
it('should not instrument file if shouldSkip returns true', function () { | ||
var result = babel.transformFileSync('./fixtures/plugin-should-not-cover.js', { | ||
plugins: [ | ||
[makeVisitor({types: babel.types}), { | ||
include: ['fixtures/plugin-should-cover.js'] | ||
}] | ||
] | ||
}) | ||
result.code.should.not.match(/statementMap/) | ||
}) | ||
result.code.should.match(/statementMap/) | ||
}) | ||
|
||
it('should not instrument file if shouldSkip returns true', function () { | ||
var result = babel.transformFileSync('./fixtures/should-not-cover.js', { | ||
plugins: [ | ||
makeVisitor({types: babel.types}) | ||
] | ||
context('package.json "nyc" config', function () { | ||
it('should instrument file if shouldSkip returns false', function () { | ||
var result = babel.transformFileSync('./fixtures/should-cover.js', { | ||
plugins: [ | ||
makeVisitor({types: babel.types}) | ||
] | ||
}) | ||
result.code.should.match(/statementMap/) | ||
}) | ||
|
||
it('should not instrument file if shouldSkip returns true', function () { | ||
var result = babel.transformFileSync('./fixtures/should-not-cover.js', { | ||
plugins: [ | ||
makeVisitor({types: babel.types}) | ||
] | ||
}) | ||
result.code.should.not.match(/statementMap/) | ||
}) | ||
result.code.should.not.match(/statementMap/) | ||
}) | ||
}) |