restartOnFileChange doesn't work after run completes normally
See original GitHub issueI just upgraded to 0.13.11 and tried the restartOnFileChange
option out for the first time.
An excerpt from my karma.conf.js
is:
autoWatch: true,
singleRun: false,
restartOnFileChange: true
}
When I kick off a test run, and then quickly edit/save a watched file; I see that the current run is cancelled and a new run starts, as per the docs.
I can repeat this process any number of times; with the same results each time (current run is cancelled, new run starts).
However, if I let the current run continue all the way through to completion; then make a change to a watched file, a new run will start, but it doesn’t run any tests.
Example console output is below. It shows:
- the end of a successful run (
Finished in 39.126 secs
,1325 tests completed
) - a change detected in the file
foo.js
- another run triggered, but with
0 tests completed
:
Finished in 39.136 secs / 1.009 secs
SUMMARY:
✔ 1325 tests completed
19 10 2015 16:42:45.754:INFO [watcher]: Changed file "foo.js".
Finished in 0.002 secs / 0 secs
SUMMARY:
✔ 0 tests completed
Issue Analytics
- State:
- Created 8 years ago
- Reactions:5
- Comments:5 (2 by maintainers)
Top Results From Across the Web
node.js - Nodemon not restarting on file change - Stack Overflow
I have tweaked it to the following: "scripts": { "start": "nodemon run prod", "build": "npm-run-all clean transpile", etc... } Still does not ...
Read more >A Complete Guide to Node.js Process Management with PM2
This in-depth guide runs you through the key features of Node.js process manager ... Start Your Node.js App in Development Mode with PM2....
Read more >Single Page Doc - PM2
Restarting PM2 with the processes you manage on server boot/reboot is critical. To solve this, just run this command to generate an active...
Read more >Configuration File - Karma
Description: When Karma is watching the files for changes, it tries to batch multiple changes into a single run so that the test...
Read more >ts-node - npm
TypeScript execution environment and REPL for node.js, with source map ... Start using ts-node in your project by running `npm i ts-node`.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Still failing.
Let me put here a comment on how this issue happens.
Step by step what happens (karma 2.0.4) and why the issue appears:
File changes.
lib/server.js line 304 : file_list_modified event is handled
lib/server.js line 306 : the handler checks config.restartOnFileChange (this one is true in our case)
lib/server.js line 307 : Server emits STOP event
lib/server.js line 309 : Server.executor.schedule() -> lib/executor.js line 34: capturedBrowsers.setAllToExecuting() -> lib/browser_collection.js line 36: set browser state to EXECUTING
static/karma.js line 235 : STOP event (emitted in step 4) is handled
static/karma.js line 236 : karma.complete method is called
static/karma.js line 204: karma emits COMPLETE event to the socket
lib/browser.js line 255 : COMPLETE event (emitted in step 8) is handled wtih onComplete function
lib/browser.js line 117 : onComplete method set the browser state to READY
Now the tests are started normally,lib/browser.js onStart method creates a new Result (line 101), and stores the total count of the specs to run…
Each spec is completed and the lib/browser.js has a notification about it in onResult (line 185). But in case if the browser state is READY, the onResult method just ignores that result: see lib/browser.js lines 190-193 comment:
So, once the restartOnFileChange config is set to TRUE, on the second run all the spec results are ignored, and the number of executed specs will be always 0.