Just a quick background. I'm trying to use Cucumber.js to do BDD in an express/node app. It works really well in Rails so I wanted keep the same framework. My problem though is that for any of my tests to run I need to manually launch the server.
For example, in my tests/scenarios, I used the zombie module's browser object to visit a page: this.browser.visit(path, function(){ ... });
To get this to work I always have to run npm start or node app.js before I run cucumber.js. I'd like for the server to start up when I call cucumber.js from the command line to run the tests instead of having to manually start it up before I run my tests.
My failed attempts:
Sample Express app with Cucumber + Makefile
That link above is to a sample repo that uses a Makefile to launch the Node.js server and run the tests. I tried copying and editing that file to use in my own project but I keep getting an error:
{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect'
}
If I manually run the server and then run the Makefile, the tests work.
Grunt.js
Ideally, I'd like to use Grunt to manage my tests but I'm having the same problem. I've started playing around with grunt-cucumber, but it doesn't have an options for launching the server before running the tests.
use grunt.js with grunt-cucumber, and grunt-connect which starts a server in the current directory.
then you could define some alias-task which first starts the connect server and then runs your cucumber tests:
grunt.registerTask("your-task-name", ["connect", "cucumber"]);