title: Unhandled Promise rejection warning: TypeError: First argument must be a string or Buffer
body: <p>Question seems to be a duplicate but I have been working to solve this from last 3 hours. Basically I'm using <code>supertest</code> &amp; <code>mocha</code> to test my API.
  I'm unable to understand which promise is not getting resolved.  </p>
  
  <pre><code>app.post('/todos', (req, res) =&gt; {
   var todo = new Todo({
   text : req.body.text
  });
   todo.save().then( (doc) =&gt; {
    res.status(200).send(doc)
    }, (e) =&gt; {
    res.status(400).end(e);
   });
  });
  </code></pre>
  
  <p>Following is the test I have written: </p>
  
  <pre><code>const expect = require('expect');
  const request = require('supertest');
  
  var {app} = require('./../server');
  var {Todo} = require('./../models/todo');
  
  // Setup database 
  beforeEach((done) =&gt; {
    Todo.remove({})
   .then(() =&gt; done())
   .catch((e)=&gt; done(e));
  }); 
  
  describe('Post /todos', () =&gt; {
  it('should create a new todo', (done) =&gt; {
  
  var text = 'Testing text';
  
  // supertest to get, post
  request(app)
    .post('/todos')
    .send({text}) // Automatic conversion to json - ES6
    .expect(200) // assertions
    .expect((res) =&gt; { // custom parsing
      expect(res.body.text).toBe(text);
    })
    .end((err, res) =&gt; {  // done directly accepted, but rather let's be more precise now - check mongodb
      if (err) {
        return done(err);
      }
      Todo.find()
        .then((todos) =&gt; {
          expect(todos.length).toBe(1);
          expect(todos[0].text).toBe(text);
          done();
        })
        .catch((e) =&gt; done(e));
    });
   });
  });
  </code></pre>
  
  <p>Please help to resolve this.
  Here's the whole error msg:</p>
  
  <blockquote>
    <p>mocha server/**/*.test.js
    Listening on port: 3000
      Post /todos
    (node:1882) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: First argument must be a string or Buffer
    (node:1882) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
        1) should create a new todo
      0 passing (2s)
      1 failing
      1) Post /todos should create a new todo:
         Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.</p>
  </blockquote>