0

I have a web application and I'm writing APIs on NodeJS.

I want to test this APIs use mocha, chai and Node-rest-client and don't open browser, but I have a problem: "I don't know How to set cookie (Authorization of header) when I ran server on localhost)

  • First, run server on localhost:3000.
  • Next, run command api testing (Set cookie to server and run API testcases).
Kalana Demel
  • 3,220
  • 3
  • 21
  • 34
Tam Vo
  • 301
  • 4
  • 13

1 Answers1

0

If you're using chrome it usuall wont save cookies for loacal host try running the following to run chrome with disabled web security.

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="C:/Chrome dev session" --args --disable-web-security

UPDATE

As in the documentation you can set Auth header with this : Documentation

var Client = require('node-rest-client').Client;

// configure basic http auth for every request
var options_auth = { user: "admin", password: "123" };

var client = new Client(options_auth);
Kalana Demel
  • 3,220
  • 3
  • 21
  • 34
  • Hi @Kalana Demel I use node-rest-client package to send a request after ran localhost in port 3000. ** I don't open browser (I only open browser when develop API) and I want to send a request with cookie (header) and node-rest-client will return result of api ** – Tam Vo May 03 '17 at 08:08