Skip to content

Commit

Permalink
fix: address issue with class instrumentation (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Oct 22, 2017
1 parent 5e51254 commit cbd1c14
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/istanbul-lib-instrument/src/visitor.js
Expand Up @@ -436,7 +436,7 @@ const codeVisitor = {
AssignmentPattern: entries(coverAssignmentPattern),
BlockStatement: entries(), // ignore processing only
ClassMethod: entries(coverFunction),
ClassDeclaration: entries(parenthesizedExpressionProp('superClass'), coverStatement),
ClassDeclaration: entries(parenthesizedExpressionProp('superClass')),
ExpressionStatement: entries(coverStatement),
BreakStatement: entries(coverStatement),
ContinueStatement: entries(coverStatement),
Expand Down
4 changes: 2 additions & 2 deletions packages/istanbul-lib-instrument/test/specs/classes.yaml
Expand Up @@ -20,7 +20,7 @@ code: |
tests:
- name: properly instruments code
out: 'MyClass'
lines: {'1': 1, '2': 1}
lines: {'2': 1}
functions: {}
statements: {'0': 1, '1': 1}
statements: {'0': 1}
branches: {'0': [1, 0]}
11 changes: 11 additions & 0 deletions packages/istanbul-lib-instrument/test/varia.test.js
Expand Up @@ -131,4 +131,15 @@ describe('varia', function () {
assert.ok(!generated);
});
});

// see: https://github.com/istanbuljs/istanbuljs/issues/110
// TODO: it feels like we should be inserting line counters
// for class exports and class declarations.
it('properly exports named classes', function () {
var v = verifier.create('export class App extends Component {};', { generateOnly: true }, { esModules: true }),
code;
assert.ok(!v.err);
code = v.getGeneratedCode();
assert.ok(code.match(/cov_(.+);export class App extends/));
});
});

0 comments on commit cbd1c14

Please sign in to comment.