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

fix(server): launch browsers when file_list is ready #1146

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var start = function(injector, config, launcher, globalEmitter, preprocess, file
var filesPromise = fileList.refresh();

if (config.autoWatch) {
filesPromise.then(function() {
filesPromise = filesPromise.then(function() {
injector.invoke(watcher.watch);
}, function() {
injector.invoke(watcher.watch);
Expand All @@ -61,15 +61,21 @@ var start = function(injector, config, launcher, globalEmitter, preprocess, file
// Some browsers did not get captured.
var singleRunBrowserNotCaptured = false;

webServer.listen(config.port, function() {
log.info('Karma v%s server started at http://%s:%s%s', constant.VERSION, config.hostname,
config.port, config.urlRoot);

var launchSingleRunBrowsers = function() {
if (config.browsers && config.browsers.length) {
injector.invoke(launcher.launch, launcher).forEach(function(browserLauncher) {
singleRunDoneBrowsers[browserLauncher.id] = false;
});
}
};

webServer.listen(config.port, function() {
log.info('Karma v%s server started at http://%s:%s%s', constant.VERSION, config.hostname,
config.port, config.urlRoot);

// Wait until fileList.refresh() is done, or else we might
// not be ready to reply to the browser's capture request.
filesPromise.then(launchSingleRunBrowsers, launchSingleRunBrowsers);
});

globalEmitter.on('browsers_change', function() {
Expand Down