How do I run postman's newman in CI environment?
<p>I'd like to run <code>newman</code> on my CI environment (solano-ci). </p>

<p><code>newman</code> is a tool that runs through requests in your postman collection.</p>

<p>I have a <code>newman</code> script in my <code>package.json</code>, and I also have a <code>npm start</code> script that starts the server at <code>localhost:3000</code>.</p>

<p><code>newman</code> is already configured with environment variables to test endpoints on port <code>localhost:3000</code>.</p>

<p>The issue is I need one script that starts the server (<code>npm start</code>) and then runs <code>npm run newman</code>. But there's a delay between when the server is available and when <code>newman</code> runs it's tests. If <code>newman</code> runs before the server is available it results in an error for each test.</p>

<pre><code>Error: connect ECONNREFUSED 127.0.0.1:3000
</code></pre>

<p>Right now here's what I tried using <a href="https://github.com/mysticatea/npm-run-all/blob/master/docs/run-p.md" rel="nofollow"><code>run-p</code></a> which works at starting two processes in parallel. Then I have to use <code>sleep</code> and set an arbitrary number of time the wait to ensure that the server is ready.</p>

<pre><code>"newman": "newman -c ./postman/api.postman_collection.json -e ./postman/local.postman_environment.json",
"newman-sleep": "sleep 10 &amp;&amp; npm run newman",
"newman-server": "run-p start newman-sleep"
</code></pre>