Tru*_*ran 13 testing request node.js chai
我正在使用node.js构建一个应用程序并使用mocha + chai进行测试.有没有办法可以为我的GET和POST chai请求添加自定义标头?
例如,我想要(半伪代码):
chai.request(server)
.get('/api/car/' + data.car_id)
.headers({'some_custom_attribute':'some_value'})
.end(function(err, res) {
//do something
});
Run Code Online (Sandbox Code Playgroud)
同样的帖子:
chai.request(server)
.post('/api/car/')
.headers({'some_custom_attribute':'some_value'})
.send({car_id: 'some_car_id'})
.end(function(err, res) {
//do something
});
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?
提前致谢!
ale*_*mac 33
使用set函数设置http标头:
chai.request(server)
.get('/api/car/' + data.car_id)
.set('some_custom_attribute', 'some_value')
.end(function(err, res) {
//do something
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18310 次 |
| 最近记录: |