TypeScripter
TypeScripter

Reputation: 909

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.

Upvotes: 3

Views: 432

Answers (1)

Louis
Louis

Reputation: 151441

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.

Upvotes: 6

Related Questions