Issue tracker missing required fields

Issue tracker missing required fields

Hey guys. I need some help with the issue tracker project. I just can’t make any good tests pass for the Missing required fields part of it. I am attempting to send a json object as a response to when the document doesnt save to the DB, and then I want to test for that response. I am not understanding why the json object isnt in the response. Here is my code in api.js. Note that Issue is a model where issue_title, issue_text and created_by are required fields

    .post(function (req, res){
      var project = req.params.project;
      MongoClient.connect(process.env.DB, {useNewUrlParser: true});
      var issue = new Issue({
        issue_title: req.body.issue_title,
        issue_text: req.body.issue_text,
        created_by: req.body.created_by,
        created_on: new Date(),
        updated_on: new Date(),
        open: true,
        assigned_to: req.body.assigned_to || '',
        status_text: req.body.status_text || ''
      });, doc)=>{
        if(err) {
          res.json({"message": "Missing required fields"});

And here is my test:

      test('Missing required fields', function(done) {
            assigned_to: 'Someone',
            created_by: 'Da man'
          .end((err, res) => {
            assert.equal(res.status, 200);
            assert.equal(res.body.message, 'Missing required fields');

Also, When I put tests that will forsure pass, the console indicates that test runs twice. And I dont know why that is, either.

 POST /api/issues/{project} => object with issue data

      ✓ Every field filled in (445ms)

      ✓ Required fields filled in

      1) Missing required fields

      ✓ Missing required fields

Basically, this test has me extremely confused and the internet has not been helpful. Any insight would be greatly appreciated. Thank you in advance.