Goedonthouden
Personal site of Pieter Bogaerts

Unit testing Angular 1.x applications while using ES6

If you are writing your Angular 1.x applications in ES6/ES2015 style it can be a pain to setup your karma.conf to test your code with Karma.

I've created a gist to get you started with unit testing your ES6 Angular 1.x applications.

Besides the projects dependencies (Angular, Angular Mocks, Babel, Babel Presets, etc.) and the default Karma dependencies (PhantomJS, Karma Chrome Launcher, etc.), there are a few other dependencies that you'll need:

  • karma-babel-preprocessor to pre-process ES6 to ES5.
  • karma-ng-html2js-preprocessor to pre-process the HTML templates.
  • karma-jasmine as the testing framework.
  • browserify-istanbul for code coverage reports.
  • isparta for ES6 code coverage reports.
  • karma-browserify" for loading your Angular modules.
  • browserify-ngannotate for the Angular dependency injection.