chai http附加设置内容typesmultipart-formdata

我想将文件作为二进制传递给我想使用chai http编写testing的函数之一,下面是代码:

chai.request('http://localhost:8085') .post('/myAPI/' + req.params.id + '/logo') .attach('image', fs.readFileSync(__dirname + '/resources/IMG_86425.jpg'), 'IMG_86425.jpg') .set('Content-Type','image/jpeg') .end((err, res) => { should.equal(err, null); res.status.should.equal(200); res.should.be.json; done(); }); 

问题是attach()固然好像把内容types更新为multipart表单数据,尽pipe我试图用image / jpeg来搭配它。 有什么我们可以做,以覆盖attach()的行为还是有任何其他方式,我可以发布二进制数据到我的function。

谢谢

附加是为了工作多部分forms的数据,发送文件为二进制我用:

 .send(fs.readFileSync(__dirname + '/resources/IMG_86425.jpg')) .set('Content-Type','image/jpeg') 

解决问题…