dimanche 11 septembre 2016

unit test document.querySelector angularJs - Karma (w Mocha)

I am having issue unit testing querySelector line in my controller

let button = document.querySelector("#"+button);
button.removeAttribute('completed');

When I am injecting the controller using componentController and try to test it fails with the following error:

 **null is not an object (evaluating 'button.setAttribute')**

I think I need to mock a "button" to exist, so that "let button" is not null but can't figure out how to do that, any help would be appreciated, thanks

Aucun commentaire:

Enregistrer un commentaire