node.js - supertest: test the redirection url -


with supertest, can test redirection code 302

var request = require('supertest'); var app = require('../server').app;  describe('test route', function(){   it('return 302', function(done){     request(app)       .get('/fail_id')       .expect(302, done);   });   it('redirect /'); }); 

how can test url objetive redirect ?

  it('redirect /', function(done){     request(app)       .get('/fail_id')       .expect('location', /\//, done);   }); 

Comments

Popular posts from this blog

javascript - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -