1

I have the following Gruntfile.js configuration (excerpt):

connect: {
  server : {
    options: {
      port: '?',
      hostname: '*',
      useAvailablePort: true,
    }
  }
}

and somewhere below:

grunt.task.run('connect');
grunt.task.run('mochaTest');

The idea is to run a selenium-webdriver test with Mocha on a random port. I would like to obtain the random port that was selected by grunt-contrib-connect, so I can pass it as a parameter to the Mocha suite. How can I get the listening port once the server has started?

  • Possible duplicate of [stop all instances of node.js server](http://stackoverflow.com/questions/14790910/stop-all-instances-of-node-js-server) – Paul Sweatte Oct 21 '15 at 11:43

0 Answers0