javascript - How to write test driven programming in node.js? -
Recently node me Presented with packages such as JS and Express, Mongodb and EJS. I have a few questions:
As a learning objective, I have created one who has created, Express, Mangode and EJS. I have all my functions in the file. I have to write test cases of all these functions How can I create a test-driven program with this example?
In my I have to write different routes to render the page and submit it etc. If there are some AJAX requests, then we have a lot of paths in I recommend you, it is from the same person of expressjs Supports, before hook, later, each and surely it supports async code. I use it in conjunction with should.js or even chai.js. A temptation test looks like this, code is from my own trial where I request I'm using SuperEgent. app.js file.
app.get ('/ login', user login); App.post ('/ login', user.loginSubmit);
app.js Enter the file when considering the paths of a page Is it like this or need to change my structure?
This ('requests permission with valid ticket', set function ('content-type', 'app / jason') .set ('authorization', 'barrier' + ACCESSTOKEN Send ({Ticket: Ticket)) .ad (function (rik, ridge) {res.should.have.property ('statusCode'). That.equals (201); var location = ..... res. Headers.should.have.property ('location'). That.is.equal (location); done ();});})
Comments
Post a Comment