Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between karma serving a file vs including a file?

When I include karma files, I can specify watched, served, included etc. Of which I wanted to understand difference between served and included. I have read documentation, so if someone can put internal details of what karma exactly does in those cases and how it impacts a test, will be useful.

like image 914
TypeScripter Avatar asked Jun 01 '26 04:06

TypeScripter


1 Answers

If a file is served, this means that the web server that Karma starts will answer to queries for this file. If it is not served, then Karma's server won't answer to queries for the file.

If a file is included, then Karma generates a <script> element for this file on the HTML that it generates to run the tests. It effectively means "load this script before you start the tests". However, there exist some cases where you want a file to be served but not included. A common example is if your code is written in the form of AMD modules. You then need to use an AMD loader to load them rather than use <script>. In such case, specified that these files are not to be included.

like image 179
Louis Avatar answered Jun 03 '26 20:06

Louis



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!