Ionic 2 Unit Tests with Webpack or angular-cli?

  1. I want to unit test our huge Ionic 2 app, Internet is full of solid examples, but with karma configured for angular-cli. Offical Ionic 2 Repo features a Unit Test Example, but for Webpack. Really unsure which path to go here?

  2. Is it hard (and recommended?) to upgrade to angular-cli from webpack for ionic 2+ ?


That’s a category error. angular-cli still uses webpack. You may wish to check out this repo.


Yes you are right of course - but I am talking about this line in that repo:

    preprocessors: {
      './karma-test-shim.js': ['webpack', 'sourcemap']

vs as can be seen in the community:

      preprocessors: {
            './src/test.ts': ['@angular-cli']


We moved to

    preprocessors: {
      './src/test.ts': ['@angular/cli']

This works well, but NOT with ionic’s own demo, which can be considered a unusable (sorry mates). I highly recommend this tutorial from the community:

There where quite a few hickups in that tutorial, mostly related to types. Remove all unnecessary types from package.json and the tutorial works a bliss.