Create a file cukelib.yml in features/support with the content:
servers:
echo:
command: node foo/index.js --port 3001
online-text: running at port 3001
Then you can say in Gherkin:
Given a running "echo" server
...
and that step library waits until the server prints running at port 3001 before finishing, so that you know your server is up and running. You can use https://github.com/originate/observable-process for this, it provides functionality for spawning and waiting for output out of the box.