Javascript 如何使用mocha和super测试测试表单数据

Javascript 如何使用mocha和super测试测试表单数据,javascript,node.js,mocha.js,supertest,Javascript,Node.js,Mocha.js,Supertest,在使用mocha和supertest进行测试时,我试图在同一请求中发送包含图像(文件)和一些文本数据的表单数据 到目前为止我都试过了 describe('Testing', () => { describe('Get a successfull endpoint message', () => { it('User should receive a successful message', (done) => { supert

在使用mocha和supertest进行测试时,我试图在同一请求中发送包含图像(文件)和一些文本数据的表单数据

到目前为止我都试过了


describe('Testing', () => {
    describe('Get a successfull endpoint message', () => {
        it('User should receive a successful message', (done) => {
            supertest('http://localhost:8080/api/v1/')
                .post('/red-flags')
                .set('Content-type', 'multipart/form-data')
                .set('token', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiZmlyc3RfbmFtZSI6ImJpaGlyZSIsImxhc3RfbmFtZSI6ImJvcmlzIiwiZW1haWwiOiJtdWhpcmVib3JpQHlhaG9vLmZyIiwicGhvbmVfbnVtYmVyIjoiMTIzNDU2Nzg5MCIsInBhc3N3b3JkIjoiJDJhJDEwJHNJNEhReUVIeUtmUUNxV3lwd21rSk9XY2RVaFBSMFlVUGVrbVkwM3prY04xR1ROZk9PellpIiwiaXNfYWRtaW4iOnRydWUsImlhdCI6MTU3NDk1MzM3Nn0.Qlmyo_ZNTdvkQvARFlUcfqZz-EOWK4bjV3gfC8zTxk0')                
                .attach('image', './sampleUploads/7bBYA.png')
                .field('thisBody', JSON.stringify({
                    "title": "this is the tittle",
                    "labels": "bro, we @   are, here, ",
                    "type": "red-flag",
                    "comment": "this is the comment about the red-flag",
                    "location": "-90,3"
                }))

                .expect('Content-Type', /json/)
                .end((err, res) => {
                    res.should.have.status(201);
                    res.should.be.a('object');
                    done();
                });
        });
    });

})

如果您有任何帮助,我们将不胜感激。

是否有任何错误消息?是否有任何错误消息?