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

Add karma.stop api method #1369

Open
ajbogh opened this issue Apr 7, 2015 · 6 comments
Open

Add karma.stop api method #1369

ajbogh opened this issue Apr 7, 2015 · 6 comments

Comments

@ajbogh
Copy link

ajbogh commented Apr 7, 2015

In certain development cases there may be a large number of unit tests that take many seconds or minutes to run. In these cases the developer may be actively programming and saving, which could execute gulp watch events that force another unit test run. Currently when a set of unit tests is running Karma can execute another set asynchronously.

It would be nice if the developer could develop a method to stop a running task before starting a new one.

Example:

if( karmaIsRunning ){
    karma.stopRun(); //stops actively running tasks before starting a new set of tests.
}
karma.start(config, function(){});
@ajbogh
Copy link
Author

ajbogh commented Apr 9, 2015

Here's a PR which accomplishes the task. Please feel free to use it for its idea, not necessarily for the code.

ajbogh#1

@dignifiedquire
Copy link
Member

Are you only interested in stopping? If so would what is talked about here #136 suffice for you? That is only talking about a command line option, but I would add an api option for it as well at the same time probably.

@ajbogh
Copy link
Author

ajbogh commented May 18, 2015

I'm interested in stopping a running task programmatically because I'm not using the command line. In my particular case I was using Gulp with gulp-karma. I found that it was nearly impossible to kill Karma in a nice way, and as the developer of gulp-karma states "Karma. just. won't. stop." [citation needed]

I made this PR to give advanced developers and plugin developers a way to stop Karma in a semi-nice manner.

#136 only accomplishes this for command-line runs.

@dignifiedquire dignifiedquire changed the title Provide API or event emitter example to cancel a running set of tests. Add karma.stop api method May 19, 2015
@dignifiedquire
Copy link
Member

Okay got it, I will probably use a different implementation, but I agree that we need to add this.

@dignifiedquire dignifiedquire added this to the v1.0 milestone May 19, 2015
@ajbogh
Copy link
Author

ajbogh commented May 19, 2015

Thanks!

@schmuli
Copy link
Contributor

schmuli commented Jul 27, 2015

I am working on an Atom plugin for running Karma, and just ran into this issue as well. Up till now, I have run Karma in the same process as Atom, without spawning, and this appears to be working.

However, when looking for a way to stop Karma, I ran into this issue. Even after looking at the recent API changes, including making the event emitter available, there still is not a way to stop Karma. Additionally, looking at the code in lib/server.js, it is still not easy to add this feature.

I should point out that I haven't found any clear documentation in Atom yet, but it may yet turn out to be a best practice to start such a plugin in a separate process, in which case I will just resort to killing the spawned process.

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

3 participants