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

Reload config file when it changes #595

Closed
jamesshore opened this issue Jun 24, 2013 · 11 comments
Closed

Reload config file when it changes #595

jamesshore opened this issue Jun 24, 2013 · 11 comments

Comments

@jamesshore
Copy link
Contributor

When the karma.conf.js file changes, reload it. Currently, changes to the config file aren't reflected in later test runs until you manually restart Karma, which can be very confusing.

If reloading the config file is difficult, a graceful exit with an error message is also fine.

This was reproduced in Karma 0.8.5. Apologies if this has been resolved since then; a quick search of the issue list didn't reveal anything.

@bracketdash
Copy link

I think this would be fine as long as there is also an option to keep whatever Karma server is currently running running, maybe an --ignore-conf-changes or something?

@vojtajina
Copy link
Contributor

This is a great feature, it's been on my todo list for quit a while now...

The problem is, that the config file can include other files ;-) and that makes watching a bit harder...

@jamesshore
Copy link
Contributor Author

Wouldn't watching the config file alone provide 80% of the value? I don't have any idea of how common it is to include other files from the config file, but if it's a significant use case, one way to handle it would be to provide a configuration option similar to client files.

@bracketdash
Copy link

But if you watch only the config file, how will Karma know to rerun tests if one of the files you're including changes?

@fr1n63
Copy link

fr1n63 commented Nov 4, 2014

Seems like a dead issue now, but +1, my situation is that I have a karma server running, watch tasks triggering changes and running tests, all fine. However when I need to add new files to the karma.conf.js, I can't find a way to update the config, so new files aren't known and I have to manually restart the karma server grunt task so it reloads the config.

I don't see why a change to the config would require re-running of the tests, changing src code should still be responsible for triggering the watch task.

@brianmhunt
Copy link
Contributor

I would just like to add that some folks (including myself) pass the karma config as a parameter to the start function e.g.

gulp.task('karma', function (done) {
    karmaServer.start(config.karma, done);
});

Where config is either stored as part of a bigger set of parameters, or generated/modified by the test runner. In any case, it would be most handy in this scenario to have a manual system for restarting.

I trust that a manual restart is subsumed by this issue, but I am happy to open another.

(p.s. ❤️ karma)

@dignifiedquire
Copy link
Member

I'm not a 100% sure this is such a great idea, so I'm closing this issue. Feel free to discuss here and I might reopen it.

@inancgumus
Copy link

@dignifiedquire I think it's a good feature. Because, we don't have to use gulp or grunt type build systems; at least npm might be sufficient.

Especially, when configuring something or when building a new project, this would become handy, I lived that. Currently, I wrote a bash script to do that, but native support would be good.

@inancgumus
Copy link

How can we add this to karma?

@ezk84
Copy link

ezk84 commented Jun 29, 2016

With grunt-contrib-watch I am able to watch the config file, the problem now is simply restarting the Karma server with the new configuration.
Running the karma:unit:start task again does not seem to reset the server. Maybe a :restart task could be used which will kill the old server and start a new one with the updated config?

@mlewand
Copy link

mlewand commented Aug 25, 2017

I was surprised to see that after adding 'karma.conf.js' to watched files in Karma config it does not reload itself. It's not a crucial feature, but it would be a nice addition, especially helpful at the beginning of Karma integration to the project.

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

No branches or pull requests

9 participants