What's the best code coverage tool to use with jasmine?

2,134 views
Skip to first unread message

Nicola Peluchetti

unread,
Jun 8, 2012, 11:20:41 AM6/8/12
to jasmi...@googlegroups.com
I've tried using jasmine with jsTestDriver but i couldn't get things working, this is probably due to the fact that i'm using jasmine-jquery. I also need a browser environment as i'm using html fixtures and i'm not sure that works in jsTestDriver. 

What other tool could i use to see the code coverage of my tests?

David Marr

unread,
Jun 20, 2012, 1:03:08 AM6/20/12
to jasmi...@googlegroups.com
Grunt has a task to watch current folder. I just stumbled across these
commands by luck but they seem to create a nice simple flow to get
started testing and writing code.

cd ~/Grunts
git init
grunt init:commonjs
(enter .git for git repo path)

Now you have a grunt managed project!

I then ran:

grunt watch

and opened a new terminal pane using iTerm2 in the same window ⌘D

then, opened vim and changed lib/Grunts.js to return axxxsome instead
of 'awesome'. Voila the other pane that is `watching` spits out a nice
list of trace statements. It runs /nodeunit/ tests but still, if i'm
starting out, I think this is easier than getting a similar workflow
working without ruby.

Dave

On Fri, Jun 15, 2012 at 8:26 PM, bernardo <bfa...@gmail.com> wrote:
> Ciao Nicola,
>
> Sei italiano immagino?
>
> Found your post looking for ways to get js coverage through jasmine myself.
> To answer your questions:
> 1) Jasmine by itself, even with Jasmine-jquery, works great with JTSD, I've
> experimented myself and it definitely works.
> 2) If you need a browser environment to load html fixtures (you technically
> don't, you can use things like env.js) JTSD is even more so the right
> choice, as it actually does run tests in 'registered' browsers so you get a
> full browser environment.
>
> I wasn't able to get JTSD to work for my specific application because I also
> use requireJS for AMD loading and it seems to be highly incompatible with
> JTSD.
> So the question remains - what other tool could I/we use to collect code
> coverage in a jasmine environment?
>
> Thanks!
> --
> You received this message because you are subscribed to the Google Groups
> "Jasmine" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/jasmine-js/-/Wi1VPADmgi0J.
>
> To post to this group, send email to jasmi...@googlegroups.com.
> To unsubscribe from this group, send email to
> jasmine-js+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/jasmine-js?hl=en.

Nicola Peluchetti

unread,
Jun 20, 2012, 7:23:36 AM6/20/12
to jasmi...@googlegroups.com
Yes i'm Italian!I'm using requirejs too, and i found out id that it is nearly impossible to use with jsTestDriver, i simply can't get my tests to run. It seems like they aren't recognized. 

Did you find out something that works?

-- 
Nicola Peluchetti
Twitter: @nik_peluchetti

On Saturday, 16 June 2012 05:26:38 UTC+2, bernardo wrote:
Ciao Nicola,

Sei italiano immagino?

Found your post looking for ways to get js coverage through jasmine myself.
To answer your questions:
1) Jasmine by itself, even with Jasmine-jquery, works great with JTSD, I've experimented myself and it definitely works.
2) If you need a browser environment to load html fixtures (you technically don't, you can use things like env.js) JTSD is even more so the right choice, as it actually does run tests in 'registered' browsers so you get a full browser environment.

I wasn't able to get JTSD to work for my specific application because I also use requireJS for AMD loading and it seems to be highly incompatible with JTSD.
So the question remains - what other tool could I/we use to collect code coverage in a jasmine environment?

Thanks!

On Friday, June 8, 2012 9:20:41 AM UTC-6, Nicola Peluchetti wrote:
I've tried using jasmine with jsTestDriver but i couldn't get things working, this is probably due to the fact that i'm using jasmine-jquery. I also need a browser environment as i'm using html fixtures and i'm not sure that works in jsTestDriver. 

What other tool could i use to see the code coverage of my tests?

On Saturday, 16 June 2012 05:26:38 UTC+2, bernardo wrote:
Ciao Nicola,

Sei italiano immagino?

Found your post looking for ways to get js coverage through jasmine myself.
To answer your questions:
1) Jasmine by itself, even with Jasmine-jquery, works great with JTSD, I've experimented myself and it definitely works.
2) If you need a browser environment to load html fixtures (you technically don't, you can use things like env.js) JTSD is even more so the right choice, as it actually does run tests in 'registered' browsers so you get a full browser environment.

I wasn't able to get JTSD to work for my specific application because I also use requireJS for AMD loading and it seems to be highly incompatible with JTSD.
So the question remains - what other tool could I/we use to collect code coverage in a jasmine environment?

Thanks!

On Friday, June 8, 2012 9:20:41 AM UTC-6, Nicola Peluchetti wrote:
I've tried using jasmine with jsTestDriver but i couldn't get things working, this is probably due to the fact that i'm using jasmine-jquery. I also need a browser environment as i'm using html fixtures and i'm not sure that works in jsTestDriver. 

What other tool could i use to see the code coverage of my tests?

On Saturday, 16 June 2012 05:26:38 UTC+2, bernardo wrote:
Ciao Nicola,

Sei italiano immagino?

Found your post looking for ways to get js coverage through jasmine myself.
To answer your questions:
1) Jasmine by itself, even with Jasmine-jquery, works great with JTSD, I've experimented myself and it definitely works.
2) If you need a browser environment to load html fixtures (you technically don't, you can use things like env.js) JTSD is even more so the right choice, as it actually does run tests in 'registered' browsers so you get a full browser environment.

I wasn't able to get JTSD to work for my specific application because I also use requireJS for AMD loading and it seems to be highly incompatible with JTSD.
So the question remains - what other tool could I/we use to collect code coverage in a jasmine environment?

Thanks!

On Friday, June 8, 2012 9:20:41 AM UTC-6, Nicola Peluchetti wrote:

Bret Little

unread,
Oct 19, 2012, 1:56:36 PM10/19/12
to jasmi...@googlegroups.com
I did get requirejs and jasmine working with jstestdriver: https://github.com/blittle/jstesting

I am having other stability issues with jstestdriver: https://code.google.com/p/js-test-driver/issues/detail?id=282&q=preload

Arundhati Wahane

unread,
Jul 16, 2013, 5:57:47 AM7/16/13
to jasmi...@googlegroups.com
u can use blanket.js with jasmine for code coverage - http://gregorsuttie.com/2013/03/18/code-coverage-for-your-javascript/
Reply all
Reply to author
Forward
0 new messages