Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): add 'listening' event with port number #1874

Merged
merged 1 commit into from
Feb 16, 2016

Conversation

karol-f
Copy link
Contributor

@karol-f karol-f commented Feb 5, 2016

Sometimes, when you want to use karma port programatically (e.g. to send manually browser to karma localhost: address), you face problem with not knowing exact port number.

Port number might be different from one set in config as sometimes you run more than one instances of karma. Below image show such situation:
Karma port changed

This PR adds 'listening' event to karma. After this event you are sure that you have correct karma port number.

You may use it like this:

let server = new Server(karmaConfig, done);
server.once('listening', function (e, port) {
    console.log(port); //port number from event
    console.log(server.get('config').port); // also correct value
});

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@karol-f
Copy link
Contributor Author

karol-f commented Feb 5, 2016

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@dignifiedquire
Copy link
Member

Thanks, could you please

@karol-f
Copy link
Contributor Author

karol-f commented Feb 10, 2016

@dignifiedquire done :)


fileListOnResolve()

server.emit('listening', 9876)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not really testing anything is it? You should probably emit the event on the mockWebServer instead

@karol-f
Copy link
Contributor Author

karol-f commented Feb 12, 2016

I've changed test to pass when mockWebServer.listen callback is executed - so when server starts listening.

@dignifiedquire
Copy link
Member

Thanks :) looks good now, if you could squash your commits into one then I can merge it.

@karol-f
Copy link
Contributor Author

karol-f commented Feb 12, 2016

Done :)

@dignifiedquire
Copy link
Member

Thanks :octocat: Just waiting for travis to get green now

@dignifiedquire dignifiedquire self-assigned this Feb 12, 2016
@karol-f
Copy link
Contributor Author

karol-f commented Feb 16, 2016

@dignifiedquire It's green

@dignifiedquire
Copy link
Member

@karol-f thanks :)

dignifiedquire added a commit that referenced this pull request Feb 16, 2016
feat(server): add 'listening' event with port number
@dignifiedquire dignifiedquire merged commit 47066ea into karma-runner:master Feb 16, 2016
@segrey
Copy link
Contributor

segrey commented May 30, 2016

@karol-f thanks for the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants