I am performing integration test, I have a scenario where i have to provide fields in form-data. I can able to provide one key and file at .attach. in my case i have to provide five keys and values in form-data in the same request. how to achieve it?
sample code i have done to perform.
const response = await request(server)
.post('url for the request')
.set({
'Content-Type': 'application/json',
})
.attach('key', 'file');
You can use .field()
to add the other text-based fields (see the docs for more details):
const response = await request(server)
.post('url for the request')
.set({
'Content-Type': 'application/json',
})
.field('category', 'Product')
.field('type', 'Image')
.field('category', 'Product')
.field('entity_no', '12354')
.attach('file', '/path/to/file');