I'm looking for tools that will help me write test cases to cover all paths through a function in Javascript. Ideally, I'd like something that will spit out a list of combinations of parameter and property values that should be tested. However, if the tool simply told me which parameters and properties have an effect on the function, that would be very useful as well.

Thanks!

edit: I'm not certain that "branch coverage" is the correct term for what I'm describing. If "code exploration" is a better term (or anything else), please add a comment.

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
If this question can be reworded to fit the rules in the help center, please edit the question.

If you're going to use a tool like this in a language that handles complexity like JavaScript does, just make sure it doesn't turn into a crutch or you'll just be maintaining code that's not as robust as it could be. Also, I'm curious, how can you hope to reliably establish code coverage in a language as mutable as JS? Methods can be applied to new object contexts and prototypes can be swapped out at any time. Functions can have params read from right to left allowing for infinite repeating patterns to the limits of memory if we so desired.
–
Erik ReppenDec 20 '12 at 7:05

@Erik: ...and why would you intentionally write JS like that, for a typical use case? -_-
–
James M. GreeneJan 1 '13 at 15:46

I'll give you the benefit of the doubt here since you have a good SO standing, but please do post other answers here that do more than promote your own blog posts. :-) This post could easily end up being flagged for spam otherwise.
–
Martijn PietersDec 20 '12 at 8:32

I have zero intention to promote my own blog post. If there would have been another article explaining how to use Istanbul, that'll would be my first choice.
–
Ariya HidayatDec 20 '12 at 16:46

3

@MartijnPieters Do you know that Ariya is the author of Phantomjs and Esprima? I mean, most code coverage, static code analysis tools and a lot of testing tools in the javascript community are base on these two tools. I mean, it's pretty relevant that he redirect to his own blog post being somewhat I'd call an expert in this field.
–
Simon BoudriasDec 31 '12 at 21:09

@SimonBoudrias: Nope, I was not aware of that.
–
Martijn PietersDec 31 '12 at 21:11

-1. According to its own webpage, JSCoverage measures line coverage, not branch coverage, as the OP asks (although from the question text, it seems that he is actually looking for a code exploration tool, not a coverage tool, which, however, JSCoverage also isn't). Also, it is ridiculously out of date: it boasts that it supports the complete language syntax described in the 3rd edition of the spec … which was released in 1999(!!!). Since then, two new revisions have been released, ES5 in 2009, and ES5.1, more than a year ago.
–
Jörg W MittagAug 22 '12 at 23:55