title: npm run test: Error: The `uri` parameter to `openUri()` must be a string, got "undefined"
body: <p><code>npm run dev</code> and the server connects to MongoDB just fine. Output below:</p>
  <p><a href="https://i.stack.imgur.com/QBNs9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QBNs9.png" alt="enter image description here" /></a></p>
  <p>However, <code>npm run test</code> and this happens:</p>
  <p><a href="https://i.stack.imgur.com/wHhfX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wHhfX.png" alt="enter image description here" /></a></p>
  <p>In package.json I have the following:</p>
  <pre><code> &quot;scripts&quot;: {
      &quot;test&quot;: &quot;mocha test&quot;,
      &quot;dev&quot;: &quot;nodemon ./bin/www&quot;
    }
  </code></pre>
  <p>Can someone explain the error? It seems like the test command requires a separate connection to the db or it's not giving mongoose enough time to connect.</p>
  <p>Full content of the test file:</p>
  <pre><code>const chai = require(&quot;chai&quot;);
  const chaiHttp = require(&quot;chai-http&quot;);
  const app = require(&quot;../app.js&quot;);
  
  chai.should();
  chai.use(chaiHttp);
  
  describe(&quot;/POST ping&quot;, () =&gt; {
    it(&quot;it should return 200 and message&quot;, (done) =&gt; {
      chai
        .request(app)
        .post(`/ping/`)
        .send({ message: &quot;hello&quot; })
        .end((err, res) =&gt; {
          res.should.have.status(200);
          res.body.should.have
            .property(&quot;response&quot;)
            .eql(&quot;Server is running. Message received: hello&quot;);
          done();
        });
    });
  });
  </code></pre>