mercredi 6 juillet 2016

How to test ajax with mocha and sinonjs (stub) from an external file

I am using mocha and sinonjs to test my ajax request. For now I am using stub. When the function is in the same document as the test there is no issue the stub takes place of the ajax. But as soon as the function is in another file the stub dont recognize the ajax but it recognize the function. Here is my fonction:

testajax.js

This is my test file:

test_ajax.js

I think i do a bad stub call but i have tried many things without any result.So i am stuck here.

Can you provide me some clues?

Kenavo

Aucun commentaire:

Enregistrer un commentaire