File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ internals.instrument = function (filename) {
109
109
110
110
// Coverage status
111
111
112
- if ( bypass [ node . range [ 0 ] ] ) {
112
+ if ( bypass [ node . range [ 0 ] ] && bypass [ node . range [ 1 ] ] ) {
113
113
return ;
114
114
}
115
115
Original file line number Diff line number Diff line change @@ -140,6 +140,19 @@ describe('Coverage', () => {
140
140
done ( ) ;
141
141
} ) ;
142
142
143
+ it ( 'bypasses marked code and reports misses correctly' , ( done ) => {
144
+
145
+ const Test = require ( './coverage/bypass-misses' ) ;
146
+ Test . method ( 1 ) ;
147
+
148
+ const cov = Lab . coverage . analyze ( { coveragePath : Path . join ( __dirname , 'coverage/bypass-misses' ) } ) ;
149
+ expect ( Math . floor ( cov . percent ) ) . to . equal ( 93 ) ;
150
+ expect ( cov . sloc ) . to . equal ( 15 ) ;
151
+ expect ( cov . misses ) . to . equal ( 1 ) ;
152
+ expect ( cov . hits ) . to . equal ( 14 ) ;
153
+ done ( ) ;
154
+ } ) ;
155
+
143
156
it ( 'ignores non-matching files' , ( done ) => {
144
157
145
158
require ( './coverage/exclude/ignore' ) ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ // Load modules
4
+
5
+
6
+ // Declare internals
7
+
8
+ const internals = { } ;
9
+
10
+ /*$lab:coverage:off$*/ const noop = function ( ) { } ;
11
+
12
+ const /*$lab:coverage:on$*/ FiveMath = function ( ) {
13
+
14
+ this . addFive = function ( value ) {
15
+
16
+ return value + 5 ;
17
+ } ;
18
+
19
+ this . subtractFive = function ( value ) {
20
+
21
+ return value - 5 ;
22
+ } ;
23
+ } ;
24
+
25
+ const fiveMath = new FiveMath ( ) ;
26
+
27
+ exports . method = fiveMath . addFive ;
You can’t perform that action at this time.
0 commit comments