Skip to content

Commit

Permalink
fix: Instrument ObjectMethod's. (#182)
Browse files Browse the repository at this point in the history
nyc currently reports the following code as containing 0 functions.  Add
ObjectMethod visitor to istanbul-lib-instrument so these are seen.
  • Loading branch information
coreyfarrell authored and bcoe committed Jun 26, 2018
1 parent 955511a commit 126f09d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/istanbul-lib-instrument/src/visitor.js
Expand Up @@ -451,6 +451,7 @@ const codeVisitor = {
BlockStatement: entries(), // ignore processing only
ClassMethod: entries(coverFunction),
ClassDeclaration: entries(parenthesizedExpressionProp('superClass')),
ObjectMethod: entries(coverFunction),
ExpressionStatement: entries(coverStatement),
BreakStatement: entries(coverStatement),
ContinueStatement: entries(coverStatement),
Expand Down
22 changes: 22 additions & 0 deletions packages/istanbul-lib-instrument/test/specs/object-method.yaml
@@ -0,0 +1,22 @@
---
name: object method
code: |
const foo = {test() { return 'value' }}
output = foo.test()
tests:
- name: object method is instrumented
out: 'value'
lines: {'1': 1, '2': 1}
functions: {'0': 1}
statements: {'0': 1, '1': 1, '2': 1}
---
name: object getter
code: |
const foo = {get test() { return 'value' }}
output = foo.test;
tests:
- name: object getter is instrumented
out: 'value'
lines: {'1': 1, '2': 1}
functions: {'0': 1}
statements: {'0': 1, '1': 1, '2': 1}

0 comments on commit 126f09d

Please sign in to comment.