Here is an example of how you would do it with supertest module.
var should = require('should'),
supertest = require('supertest');
var request = supertest('localhost:3000');
describe('upload', function() {
it('a file', function(done) {
request.post('/your/endpoint')
.field('extra_info', '{"in":"case you want to send json along with your file"}')
.attach('image', 'path/to/file.jpg')
.end(function(err, res) {
res.should.have.status(200); // 'success' status
done();
});
});
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…