arrow icon indicating copy to clipboard operation
arrow copied to clipboard

How to get Arrow to work with Istanbul ?

Open nottoseethesun opened this issue 10 years ago • 9 comments

Pure mocha works with istanbul in my project, but arrow does not.

Statements: 82.93% (34 / 41)      Branches: 53.57% (15 / 28)      Functions: 100% (13 / 13)      Lines: 82.93% (34 / 41)      Ignored: none 

File        Statements      Branches        Functions       Lines
full/       83.33%  (20 / 24)   50.00%  (8 / 16)    100.00% (8 / 8) 83.33%  (20 / 24)
simple/     82.35%  (14 / 17)   58.33%  (7 / 12)    100.00% (5 / 5) 82.35%  (14 / 17)

The above js code coverage report could be successfully generated by attaching to a pure mocha command:

istanbul cover _mocha example/nodejs/test/TestExamples.js -- -R spec

But unfortunately, when using arrow:

istanbul cover arrow example/nodejs/test/TestExamples.js -- --engine=mocha --testTimeOut=180000

we would get nothing covered at all:

Statements: 100% (0 / 0)      Branches: 100% (0 / 0)      Functions: 100% (0 / 0)      Lines: 100% (0 / 0)     

Using the "--coverage" switch for arrow, per its documentation too (in https://github.com/yahoo/arrow/tree/master/docs/arrow_cookbook), also reports "0 / 0" coverage at last (printed after test done, appended to arrow's report). Not much more clue found in arrow's doc.

What is the correct way to use istanbul with arrow (or output coverage data with arrow)?

Is there any handy usage example of arrow with code coverage report generated by istanbul? Or any known project on github that uses arrow for testing while generates its code coverage data with istanbul?

Here is some example code for reproducing the Arrow zero-coverage issue:

tar xzvf foo.tar.gz
cd foo
npm install && npm test

Look at the three repeated tests as written in the npm test scripts in package.json. Only the first test (pure mocha + istanbul way) outputs the right coverage report:

./node_modules/yahoo-arrow/node_modules/.bin/istanbul cover ./node_modules/yahoo-arrow/node_modules/.bin/_mocha test/MyTest.js -- -R spec

But the following two other ways with Arrow do not.

./node_modules/.bin/arrow test/MyTest.js --engine=mocha --coverage
./node_modules/yahoo-arrow/node_modules/.bin/istanbul cover ./node_modules/.bin/arrow test/MyTest.js -- --engine=mocha

They report nothing covered at all:

Statements: 100% (0 / 0)      Branches: 100% (0 / 0)      Functions: 100% (0 / 0)      Lines: 100% (0 / 0)     

Example code.

nottoseethesun avatar Feb 10 '14 08:02 nottoseethesun

@christopherbalz Thanks for reporting. Let me take a look.

pranavparikh avatar Apr 28 '14 22:04 pranavparikh

Let me know if you need any help.

nottoseethesun avatar May 07 '14 07:05 nottoseethesun

Any status update on this?

nottoseethesun avatar Jul 02 '14 20:07 nottoseethesun

@christopherbalz ,

Havent got a chance yet to look into this. Do you mind sending a PR ?

pranavparikh avatar Jul 09 '14 16:07 pranavparikh

Attached to the first entry in this ticket is a reproduction of the issue: http://treelogic-swe.com/opensource-download/foo.tar.gz Let me know if that requires clarification and I will create it.

You must mean "pull request" by PR - yes I will do so if time allows.

nottoseethesun avatar Jul 09 '14 17:07 nottoseethesun

Also, could we please get this labeled as a bug, since we provided an example of the bug ?

nottoseethesun avatar Jul 20 '14 16:07 nottoseethesun

@christopherbalz

This project is no longer being actively worked upon. Please feel free to send PR if time permits.

pranavparikh avatar Jul 22 '14 23:07 pranavparikh

Ok, thank you, will do.

nottoseethesun avatar Jul 23 '14 00:07 nottoseethesun

Coverage report now works by adding "--lib" option in this case: ./node_modules/.bin/arrow test/MyTest.js --engine=mocha --coverage --lib=./src

In fact, I found "--lib=./src" specifies the exact source code set to analyse in the coverage report by running the test, though here the name 'lib' looks confusing for including target source set.

I have created a pull request to the documentation that clarify the "--lib" usage in arrow code coverage: https://github.com/yahoo/arrow/pull/276

This issue can be closed now.

maxiaohao avatar Aug 04 '14 08:08 maxiaohao