Skip to content

Commit

Permalink
fix: Honor istanbul ignore next hints placed before export statement. (
Browse files Browse the repository at this point in the history
…#298)

Fixes #297
  • Loading branch information
coreyfarrell committed Feb 18, 2019
1 parent f7f6e7c commit f24795d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/istanbul-lib-instrument/src/visitor.js
Expand Up @@ -484,6 +484,8 @@ const codeVisitor = {
ArrowFunctionExpression: entries(convertArrowExpression, coverFunction),
AssignmentPattern: entries(coverAssignmentPattern),
BlockStatement: entries(), // ignore processing only
ExportDefaultDeclaration: entries(), // ignore processing only
ExportNamedDeclaration: entries(), // ignore processing only
ClassMethod: entries(coverFunction),
ClassDeclaration: entries(parenthesizedExpressionProp('superClass')),
ObjectMethod: entries(coverFunction),
Expand Down
35 changes: 35 additions & 0 deletions packages/istanbul-lib-instrument/test/varia.test.js
Expand Up @@ -66,6 +66,41 @@ describe('varia', function() {
);
});

it('honors ignore next for exported functions', function() {
/* https://github.com/istanbuljs/istanbuljs/issues/297 */
var v = verifier.create(
'/* istanbul ignore next*/ export function fn1() {}' +
'/* istanbul ignore next*/ export default function() {}',
{ generateOnly: true },
{ esModules: true }
),
code;
assert.ok(!v.err);
code = v.getGeneratedCode();
assert.ok(
code.match(
/}\(\);export function fn1\(\){}export default function\(\){}/
)
);
});

it('instruments exported functions', function() {
/* https://github.com/istanbuljs/istanbuljs/issues/297 */
var v = verifier.create(
'export function fn1() {}' + 'export default function() {}',
{ generateOnly: true },
{ esModules: true }
),
code;
assert.ok(!v.err);
code = v.getGeneratedCode();
assert.ok(
code.match(
/}\(\);export function fn1\(\){cov_(.+)\.f\[\d+\]\+\+;}export default function\(\){cov_(.+)\.f\[\d+\]\+\+;}/
)
);
});

it('returns last coverage object', function(cb) {
var instrumenter = new Instrumenter({
coverageVariable: '__testing_coverage__'
Expand Down

0 comments on commit f24795d

Please sign in to comment.