title: mocha - send json to post express route
body: <p>I'm trying to send some json data to my <code>'/sign_up'</code> route in mocha test.</p>
  
  <pre><code>request = require 'supertest'
  express = require 'express'
  app = express()
  Authentication = require("#{specDir}/../apps/authentication/routes")
  authenticate = new Authentication app
  
  Factory = require "#{specDir}/factories/user"
  user = Factory.build 'user'
    it 'creates an account', (done) -&gt;
      request(app).post('/sign_up').set('Accept', 'application/json').send(user).end (err, res) -&gt;
        expect(res.statusCode).to.equal 200
        done()
  </code></pre>
  
  <p>However <code>req.body</code> in the callback function is <code>undefined</code>. Below I've shown a snippet of my route callback</p>
  
  <pre><code>  @app.post '/sign_up', (req, res) -&gt;
      res.format
        html: -&gt; res.status(406).send 'invalid Content-Type'
        json: -&gt;
          console.log req.body
          res.status(200).send status: 'ok'
  </code></pre>
  
  <p>Probably I'm missing some small detail, but can't see what.. any ideas?</p>
  
  <p>P.S. I'm well aware of that the tests pass and it does what it should, but before I move on to write more tests I gotta know how to send some data.</p>