title: How to unit test file upload with Supertest -and- send a token?
body: <p>How can I test a file upload with a token being sent? I'm getting back "0" instead of a confirmation of upload.</p>
  
  <p><strong>This is a failed test:</strong></p>
  
  <pre><code>var chai = require('chai');
  var expect = chai.expect;
  var config = require("../config");  // contains call to supertest and token info
  
    describe('Upload Endpoint', function (){
  
      it('Attach photos - should return 200 response &amp; accepted text', function (done){
          this.timeout(15000);
          setTimeout(done, 15000);
          config.api.post('/customer/upload')
                .set('Accept', 'application.json')
                .send({"token": config.token})
                .field('vehicle_vin', "randomVIN")
                .attach('file', '/Users/moi/Desktop/unit_test_extravaganza/hardwork.jpg')
  
                .end(function(err, res) {
                     expect(res.body.ok).to.equal(true);
                     expect(res.body.result[0].web_link).to.exist;
                 done();
             });
      });
  });
  </code></pre>
  
  <p><strong>This is a Working test:</strong></p>
  
  <pre><code>describe('Upload Endpoint - FL token ', function (){
     this.timeout(15000);
      it('Press Send w/out attaching photos returns error message', function (done){
      config.api.post('/customer/upload')
        .set('Accept', 'application.json')
        .send({"token": config.token })
        .expect(200)
        .end(function(err, res) {
           expect(res.body.ok).to.equal(false);
           done();
      });
  });
  </code></pre>
  
  <p>Any suggestions are appreciated!</p>