在摩卡节点请求选项
我想在我的unit testing中提供自定义标题,目前我的unit testing是
request(sails.hooks.http.app) .post('/myurl') .send(userDetails) .expect('Content-Type', /json/) .expect(200) .end(function (err, res) { if(err) throw err; //do something });
我想添加标题
var options = { url: 'community', headers: { 'Authorization': 'Bearer ' + authToken } };
当我在npmjs中看到请求的文档。 它要求我提供选项来请求
request(options, callback);
我如何提供自定义标题在我的情况下,即如果我在unit testing中提供req参数作为选项对象?
我相信supertest
有一个set()
来设置请求标题:
request(sails.hooks.http.app) .post('/myurl') .set('Authorization', 'value') .send(userDetails) .expect('Content-Type', /json/) .expect(200)
- 告诉摩卡在哪里寻找testing文件
- 使用webpack的require.ensure函数为javascript模块编写testing
- 来自浏览器的Node.js和Mochatesting
- 摩卡/ Should.js使用asynchronousfunction
- 在摩卡testing中的for循环中进行顺序mongoose查询
- 在浏览器中使用Webpack和mocha-loader从React应用程序运行Mocha规范
- sails.js + mocha + supertest + sinon:如何存储sails.js控制器函数
- 我如何testing一个基本的JavaScript文件与摩卡?
- aws-sdk s3上传不工作从摩卡testing