TypeError:“string”必须是string,Buffer或ArrayBuffer

使用Multiparty NPM模块为multipart / form-data开发了一个Node代理应用程序。 我想用Mocha和Chai来testing应用程序。 在运行testing用例时,我得到“TypeError:”string“必须是string,缓冲区或ArrayBuffer”错误。

我的代码片段是:

it('<test case description comes here>', (done) => { chai.request(app) .post('<my post url comes here>') .set('Content-Type', 'multipart/form-data; boundary=' + Math.random()) .send({emailField: 'test@xyz.com', xyzField: 'Some Data'}) .attach('file', 'test.txt') .end((error, result) => { if (error) { console.log(error); } result.should.have.status(200); result.should.not.be.empty; done(); }); }); 

任何帮助,将不胜感激。