发现以下关于如何在express中测试中间件的提示:
https://github.com/visionmedia/express/blob/master/test/req.xhr.js我想知道为什么我的考试总是过去。直到我注意到,当我从快递复制测试时,他们表现得一样。我试着拧紧它们但是它们不断传递:
https://github.com/visionmedia/express/blob/master/test/req.xhr.js
我在这里缺少什么?
it('should return true when X-Requested-With is xmlhttprequest', function(done){
var app = express();
app.use(function(req, res){
req.xhr.should.be.false; //set to false, to fail the test but it still passes
res.end();
});
request(app)
.get('/')
.set('X-Requested-With', 'xmlhttprequest')
.end(function(res){
done();
})
})