mercredi 22 avril 2015

QUnit - testing plugin method calls, generic statements, etc

Few things to know:

  • My app heavily uses
    • jQuery
    • jQuery plugins (jQuery UI, chosen, datatable, etc)
    • Bootstrap

So I am very new to JS unit testing and maybe it will sound very very lame but I have a few questions below:

I have recently started qUnit to test my JS code and have used blanket.js to do code coverage.

Blanket JS output shows code like this as uncovered. I am wondering how/what can I do to get them covered?

    Example 1
    function resetForm(form)    {
      form.reset(); // This line shows not covered
    }

    Example 2
    $('a.staticLink').on('click', function(e)   {
      e.preventDefault();// This line shows not covered
    });

Similarly all generic bootstrap functions like show(), hide() show as not covered.

Even statements that just have a plugin call show as not-covered

       $(".chosen-select").chosen(); //not covered

Any help is greatly appreciated

Aucun commentaire:

Enregistrer un commentaire