Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma: no cache on file server

Tags:

karma-runner

When I do some setup on my test suite, I sometimes need to debug the produced html file.

The good thing is, there is a debug feature: debug button

In order to do that, I run karma start --no-single-run.

But on every file change I make, I need to kill the process and restart it, otherwise, cached files are served:

cached

How can I prevent the server from caching in this specific situation? Anyways, most of the time I run in single-run mode so caching hasn't much interest for me.

Thanks

like image 279
Augustin Riedinger Avatar asked Dec 19 '25 14:12

Augustin Riedinger


2 Answers

--auto-watch may help:

karma start --no-single-run --auto-watch

If you change some files, karma-runner will reload (and cache) them, then it will run tests again automatically. If you refresh debug.html page after that, you will get a new version of these files without restarting karma-runner.

like image 61
idmitme Avatar answered Dec 24 '25 12:12

idmitme


If you have this issue when running the tests in IntelliJ have a look at this workaround.

function runTests() {
  var serverPort = cli.getServerPort();
  var urlRoot = cli.getUrlRoot() || '/';
  if (urlRoot.charAt(urlRoot.length - 1) !== '/') {
    urlRoot = urlRoot + '/';
  }
  runWithConfig({
    port: serverPort,
    refresh: false,     // set this flag to true
    urlRoot: urlRoot
  });
}

It's a known, not yet fixed issue in the karma-intellij plugin.

like image 26
S.Klechkovski Avatar answered Dec 24 '25 11:12

S.Klechkovski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!