javascript - Unit testing with an API involved -
I'm a little newbie for unit testing, so be easy for me I have some modules that ask for a Resipple API is. I think in every test suite, I'm using some lines of code to spin a simple ExpressJS web server to use some routes which I can call with my tests. This can be the old writing in every test suite. There should be a better way of doing this. Any suggestions?
My code is running on all javascript in my nodejs and browser btw
UPDATE: I am not sure if I have explained well in my original comment, then here is something
Description ("person", function () (this ( "(Rest Person = New Person (); // Person is posted on" / api / person / "person.save (function () {Hope (person._id) .to.be (" id ");
Generally I will create a small express server with the following route:
App post ("/ Api / person / *", function (req), res) {res.send (200, {data: 0123})});
But it seems to me that I'm stinking to do this for every test suite to write. If this can be accomplished using stubborn or spies, then this thing I would love to see an example of how or if I am doing all this wrong then please tell me what I can do differently thanks!
You can use your AJAX calls for remorse / spy May include, check that executed were many times that parameters were passed. Check examples from the Sinon website for more information.
Comments
Post a Comment