TypeError:" string"必须是字符串,缓冲区或ArrayBuffer

时间:2017-05-03 07:59:19

标签: node.js mocha chai

使用Multiparty NPM模块为多部分/表单数据开发了一个节点代理应用程序。我想使用MochaChai来测试应用程序。在运行测试用例时,我得到" TypeError:" 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();
            });
});

任何帮助都将不胜感激。

0 个答案:

没有答案
相关问题