Hi Brett,
I have been using your solution for a while as well and admit it is a smart solution.
I had the same problem with running tests, I needed a guarantee that the server is running before I kick off my e2e tests.
To solve this I had to change my build a bit. First I needed to use Webpack dev-server-middleware so that instead of it creating an Express app for me, I provide it with the App. This way I can subscribe a callback to be notified when the server is up and running.
Second if you use npm-run-all inside a nodejs file via `require` syntax it has a very nice Promise based API. So, I chain it to a custom Promise I return from `app.listen` and then I run other tasks sequentially via chaining npm-run-all promises. Here is a snippet of what I mean:
const app = express();
…
app.use(webpackDevServerMiddleware);
…
new Promise((res, rej) => {
app.listen(PORT, () => res());
}).then(() => {
return npmRunAll.exec(‘test:e2e’);
}).then(() => {
// use Node exit command to make sure you terminate the process after the tests are run.
});