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?