Send a post request with parameters using jasmine test case (node.js)

926 views
Skip to first unread message

Sachin

unread,
Aug 21, 2014, 9:14:05 AM8/21/14
to jasmi...@googlegroups.com
Hi ,

I am writing test cases for node js. Please tell me how can I send a post request having parameters.
I am writing in this way but it is showing data undefined.


var request =require('request');
describe('afterEach Timeout', function(){
  afterEach(function(done) {
      setTimeout(done, 1000);
  }, 100);
 
  it("should respond with hello world", function(done) {
  var body=new Object( );
        body.email="s...@sa.com";
        body.password="pass";

      request.post("http://localhost:3000/loginAuth",body, function(error, response, body){
        expect(response).not.toBeNull();
        console.log(response);
        done();
      });
    });
});

Thanks

Pulak Bhattacharyya

unread,
Aug 22, 2014, 10:34:06 AM8/22/14
to jasmi...@googlegroups.com
I do not think you need to send original request to Node server instead you need to mock it.
Reply all
Reply to author
Forward
0 new messages