Guest User

Untitled

a guest
Nov 26th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. var APIeasy = require('api-easy'),
  2. assert = require('assert');
  3.  
  4. var suite = APIeasy.describe('/api');
  5. var urlRedir;
  6.  
  7. suite.discuss('Test Redirection API')
  8. .use('localhost', 3000)
  9. .setHeader('Content-Type', 'application/json')
  10. .followRedirect(false)
  11. .path('/login')
  12. .post({user: {email:'tmp@gmail.com', password:'tmp'}})
  13. .expect(302)
  14. .expect('redirect content', function (err, res, body) {
  15. urlRedir = res.headers.location;
  16. })
  17. .next()
  18. .get(urlRedir) //the urlRedir is null, the real url is /login and this is from path()
  19. .expect(200)
  20. .expect('get redir url content', function(err, res, body){
  21. console.log(body);
  22. })
  23. .export(module);
Add Comment
Please, Sign In to add comment