Configuration and setting up

In terms of configuration, when using the Angular CLI, you don't have to do anything to make it work. You can, as soon as you scaffold a project, run your first test and it will work. As you venture deeper into unit testing in Angular, you will need to be aware of a few concepts that leverage your ability to test different constructs, such as components and directives. The Angular CLI is using Karma as the test runner. What we need to know about Karma is that it uses a karma.conf.js file, a configuration file, in which a lot of things are specified, such as:

  • The various plugins that enhance your test runner.
  • Where to find the tests to run?  It should be said that there is usually a files property in this file specifying where to find the application and the tests. For the Angular CLI, however, this specification is found in another file called src/tscconfig-spec.json.
  • Setup of your selected coverage tool, a tool that measures to what degree your tests cover the production code.
  • Reporters, report every executed test in a console window, to a browser, or through some other means.
  • Browsers to run your tests in: for example, Chrome or PhantomJS.

Using the Angular CLI, you most likely won't need to change or edit this file yourself. It is good to know that it exists and what it does for you.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset