So about a month ago I asked a question regarding superagent and sending files, but got no response at all. I would still like to find out how to do this as I enjoy using su
No one asked, but I think this might benefit a few.
Using async/await
describe('My App - Upload Module', function(){
it('Upload Module - ERROR - upload an expired file', async function(){
try{
let res = await _upload_license_file("/tmp/test_license.xml");
}catch(err){
err.should.have.status(422);
}
});
});
async function _upload_license_file(fileLocation){
return superAgent.post(base_url + "/upload")
.set('Authorization', 'Bearer '+API_TOKEN)
.set('Content-Type', 'multipart/form-data')
.attach('xml_file', fileLocation)
}
I have worked here the error module, you can process the response object the similar way for pass cases.