Wednesday, 3 May 2017

TypeError: "string" must be a string, Buffer, or ArrayBuffer

Developed a Node proxy app using Multiparty NPM module for multipart/form-data. I would like to test the application using Mocha and Chai. While running the test case I am getting the "TypeError: "string" must be a string, Buffer, or ArrayBuffer" error.

My code snippet is:

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();
            });
});

Any help would be appreciated.



via Praveen

No comments:

Post a Comment