Not necessarily relates to c8, but I was asked to create an issue here.
I have general struggle with coverage features in node.js.
I tried using c8 package and node.js' inspector module.
Neither of them gives correct lineNumber, columnNumber and ranges (startOffset, endOffset), unfortunately.
c8
when I run c8 node test.js where test.js is this file:
function foo() {
console.log(123)
}
foo()
I get this in the generated report:
{"functionName":"foo","ranges":[{"startOffset":62,"endOffset":99,"count":1}]
Note the startOffset":62 when there is 44 characters total in test.js. I am not even speaking about "endOffset":99.
inspector
after not successing with c8 I tried to place in my test.js code from this example
and run node test.js
then I got this:
{"functionName":"session.post","scriptId":"66","url":"file:///home/nurbol/www/sandbox/test.js","lineNumber":5,"columnNumber":32},"hitCount":0,"children":[16]}
Note the "lineNumber":5 when there is no anything on line number 5!
Then @bcoe gave me an advice to take into accunt require('module').wrapper[0] that is inserted by node.js. But if done so, line number 5 contains session.connect and not session.post (see the json above)!
My setup:
Linux (Lubuntu).
Node 11.2.0 (also tested in 10.13.0 with the same results)
c8 3.2.1
Not necessarily relates to c8, but I was asked to create an issue here.
I have general struggle with coverage features in node.js.
I tried using c8 package and node.js' inspector module.
Neither of them gives correct
lineNumber,columnNumberandranges(startOffset,endOffset), unfortunately.c8
when I run
c8 node test.jswhere test.js is this file:I get this in the generated report:
{"functionName":"foo","ranges":[{"startOffset":62,"endOffset":99,"count":1}]Note the
startOffset":62when there is 44 characters total intest.js. I am not even speaking about"endOffset":99.inspector
after not successing with c8 I tried to place in my test.js code from this example
and run
node test.jsthen I got this:
{"functionName":"session.post","scriptId":"66","url":"file:///home/nurbol/www/sandbox/test.js","lineNumber":5,"columnNumber":32},"hitCount":0,"children":[16]}Note the
"lineNumber":5when there is no anything on line number 5!Then @bcoe gave me an advice to take into accunt
require('module').wrapper[0]that is inserted by node.js. But if done so, line number 5 containssession.connectand notsession.post(see the json above)!My setup:
Linux (Lubuntu).
Node 11.2.0 (also tested in 10.13.0 with the same results)
c8 3.2.1