arrow
arrow copied to clipboard
How to get Arrow to work with Istanbul ?
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)
@christopherbalz Thanks for reporting. Let me take a look.
Let me know if you need any help.
Any status update on this?
@christopherbalz ,
Havent got a chance yet to look into this. Do you mind sending a PR ?
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.
Also, could we please get this labeled as a bug, since we provided an example of the bug ?
@christopherbalz
This project is no longer being actively worked upon. Please feel free to send PR if time permits.
Ok, thank you, will do.
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.