UPDATE:
I got this working… it was so simple.
res.body
needed to be res.body.issues[0]
in my case.
My issues were being created in an array in each project object.
test('Every field filled in', function(done) {
chai.request(server)
.post('/api/issues/test') // there is a project called test
.send({
issue_title: 'Title',
issue_text: 'text',
created_by: 'Functional Test - Every field filled in',
assigned_to: 'Chai and Mocha',
status_text: 'In QA'
})
.end(function(err, res){
console.log(res.body); // to confirm that an issue was created
expect(err).to.be.null;
assert.equal(res.status, 200);
assert.property(res.body, 'issue_title'); // fails at this point
assert.equal(res.body.issue_title, 'Title');
done();
});
});
I have created a project called ‘test’.
When the test ‘Every field filled in’ runs, it creates an issue in the database under project ‘test’.
I can’t get any assert to succeed.
I have tried changing the ‘res’ because my issues are in an array inside the project object.
assert.property(res.body.issues, 'issue_title');
assert.equal(res.body.issues.issue_title, 'Title');