To configure Karma, the test runner, there are karma.conf.js and karma-test-shim.js.

karma.conf.js

First, the ‘framework’ is set to Jasmine. Then karma-jasmine, karma-chrome-launcher, and karma-htmlfile-reporter are set as required plugins and ‘customLaunchers’ is set to launch the Chrome browser.

Next there is a big block that tells which files are to be sent to the browser and which are to be served by the Karma webserver.

The next interesting configuration is for the reporters which is set to ‘progress’ and also ‘html’ which is configured in the next block and is set to output a tests.html file at the end of the test run.

Lastly, some miscellaneous items like the the port, colors (for reporters and logs), logLevel, autoWatch (for automatically running the tests if a file changes, the browser (Chrome), and singleRun which tells Karma to run the tests once and then exit (false).

typings.json tells the TypeScript compiler how to handle certain JavaScript libraries.

In typings.json definitions for how to handle Jasmine and es6-shim are configured.

Up next, systemjs.config.js which configures the SystemJS module loader.

The map block configures a module alias to a location or package. ‘app’ maps to the ./app directory. ‘rxjs’ maps to node_modules/rxjs, ‘angular2-in-memory-web-api’ maps to node_modules/angular2-in-memory-web-api, and ‘@angular’ maps to node_modules/@angular.

The packages block allows configuration of a particular map. ‘app’ is configured with a main of main.js and defaultExtension is set to js. ‘rxjs’ and ‘angular2-in-memory-web-api’ are configured with defaultExtension set to js as well.

Finally, there’s some actual JavaScript code to set defaultExtension to js for all the @angular packages and System.config() is called with the configuration block to make the changes to the system.

Time to look at tsconfig.js which is used to configure TypeScript.

The first block configures the compiler options. The target option is set to es5 so the ECMAScript target version is ECMAScript 5. The module option is set to commonjs so CommonJS is used for module loading. The moduleResolution is set to node so the compiler mimics Node.js’s runtime module resolution. The sourceMap option is set to true so that .map files are generated (.map file are created so debuggers can map compiled code to the source). The emitDecoratorMetadata and experimentalDecorators are set to true to support class metadata using decorators. The removeComments option is true so that comments are available in the compiled .js file. The noImplicitAny and suppressImplicitAnyIndexErrors are set to true so the compiler is more strict and will fail if a type cannot be inferred.

The next block is the exclude section which tells the compiler what directories to ignore. The node_module, typings/main, and typings/main.d.ts are set to be ignored by the compiler.

Another useful excercise in learning what’s going on with an Angular project. Steady progress for the win!