How to test file upload with Jasmine BDD

jasmine, javascript

Solution

I would take a look at using the helper library Sinon.js. You can mock the XMLHttpRequest object to intercept the post request, and verify that your plugin code is submitting images correctly. In particular, take a look at this part of the Sinon.js documentation:

http://sinonjs.org/docs/#server

Problem

I'm using jQuery file upload plugin for managing image file uploads. What will be the right way to test image submission with Jasmine.

Original source