It's probably that your app is not using bodyParser middleware in place.
app.use(express.bodyParser());
From the expressjs docs:
req.body
This property is an object containing the parsed request body. This feature is provided by the bodyParser() middleware, though other body parsing middleware may follow this convention as well. This property defaults to {} when bodyParser() is used.
Here you have a complete example
var express = require('express');
var request = require('supertest');
var assert = require('assert');
var app = express();
app.use(express.bodyParser());
app.get('/', function(req, res) {
res.send('ok');
});
app.post('/createQuestion', function(req, res) {
var message = req.body.partA + ' ' + req.body.partB;
res.send(message);
});
describe('testing a simple application', function() {
it('should return code 200', function(done) {
request(app)
.get('/')
.expect(200)
.end(function(err, res){
if(err) {
done(err);
} else {
done();
}
});
});
it('should return the same sent params concatenated', function(done) {
request(app)
.post('/createQuestion')
.send({ partA: 'Hello', partB: 'World'})
.expect(200, 'Hello World')
.end(function(err, res){
if(err) {
done(err);
} else {
done();
}
});
});
});