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

Watching doesn't start when debugging #41

Closed
abaksha-sc opened this issue Dec 6, 2018 · 4 comments
Closed

Watching doesn't start when debugging #41

abaksha-sc opened this issue Dec 6, 2018 · 4 comments

Comments

@abaksha-sc
Copy link

abaksha-sc commented Dec 6, 2018

I use the following config to run karma (to debug unit tests):
karma start tests/config.js --auto-watch --no-single-run --no-coverage --no-browsers
And then I open http://localhost:9876/debug.html directly in browser to run tests.
In this case watching doesn't start, because event run_start does not dispatch.
It works when open http://localhost:9876/ at first, but I would like to have a possibility to skip this step, because in most cases tab with debug.html is opened and I just refresh it.

Maybe need to start watching without event run_start?

@jlmakes
Copy link
Owner

jlmakes commented Dec 6, 2018

Do you know which flag prevents the run_start event?


Related:

https://glebbahmutov.com/blog/debugging-karma-unit-tests/
http://karma-runner.github.io/3.0/dev/public-api.html

@abaksha-sc
Copy link
Author

abaksha-sc commented Dec 7, 2018

There are two flags prevent run_start: --no-single-run --no-browsers

1. Here is event fires when config.noSingleRun:
https://github.com/karma-runner/karma/blob/bb022a7fa06042eb0d98ed72c75b74038128d9c0/lib/server.js#L311

But I use flag --no-single-run

2. And here are event fired when capturedBrowsers is not empty:
https://github.com/karma-runner/karma/blob/bb022a7fa06042eb0d98ed72c75b74038128d9c0/lib/executor.js#L30
https://github.com/karma-runner/karma/blob/bb022a7fa06042eb0d98ed72c75b74038128d9c0/lib/middleware/runner.js#L38

But I use flag --no-browsers.

Because of this event run_start doesn't fire when I open debug.html directly.
Event fires when I open http://localhost:9876/. But it is a redundant step for me (and my colleagues).

@abaksha-sc
Copy link
Author

abaksha-sc commented Dec 7, 2018

May be just change event run_start to listening ?
https://github.com/karma-runner/karma/blob/bb022a7fa06042eb0d98ed72c75b74038128d9c0/lib/server.js#L175

It dispatches when karma server is ready (see previous line with this.log.info). Here is a documentation for this: http://karma-runner.github.io/3.0/dev/public-api.html
I think it is a good point to start watching.

P.S. I tested this solution, it works with --no-single-run --no-browsers

@jlmakes jlmakes changed the title Watching doesn't start Watching doesn't start when debugging Dec 8, 2018
@jlmakes
Copy link
Owner

jlmakes commented Jan 2, 2019

Ahh I see, the listening event was added in Karma 2.

I'm in the process of adding support for rollup@1.0.0 so I'll make sure this issue is resolved in the next release: karma-rollup-preprocessor@7.0.0 coming soon...

@jlmakes jlmakes mentioned this issue Jan 12, 2019
@jlmakes jlmakes closed this as completed in 3d9058b Feb 6, 2019
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

2 participants