I'm writing a generic test function with chai.request, here is what I have:
//this is in some function
var file = fs.readFileSync(__dirname + '/../test/files/' + args.fileName);
chai.request(server)
.post('/v2')
.field('email', args.email)
.field('subject', args.subject)
.attach('fileName', file, args.fileName)
.end((err, res) => {
//some test conditions
done();
});
This works great if there is only 1 file passed, the problem is that sometimes I need to pass in an array of files, but I have no idea how to attach those when I'm not sure of the number of files coming in.
via Mankind1023
No comments:
Post a Comment