# Ionic 2 Unit Tests with Webpack or angular-cli?

**URL:** <https://forum.ionicframework.com/t/ionic-2-unit-tests-with-webpack-or-angular-cli/87165>\
**Category:** ionic-v3\
**Created:** [April 20, 2017, 1:25am UTC](https://forum.ionicframework.com/t/ionic-2-unit-tests-with-webpack-or-angular-cli/87165 "2017-04-20T01:25:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon70733690](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@anon70733690](https://forum.ionicframework.com/u/anon70733690)\
**Post date:** [April 20, 2017, 1:25am UTC](https://forum.ionicframework.com/t/ionic-2-unit-tests-with-webpack-or-angular-cli/87165/1 "2017-04-20T01:25:44Z")

</div>

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+ ?

---

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [April 20, 2017, 3:53am UTC](https://forum.ionicframework.com/t/ionic-2-unit-tests-with-webpack-or-angular-cli/87165/2 "2017-04-20T03:53:45Z")

</div>

> [@anon70733690](#):
>
> Is it hard (and recommended?) to upgrade to angular-cli from webpack

That’s a category error. angular-cli still uses webpack. You may wish to check out [this repo](https://github.com/driftyco/ionic-unit-testing-example).

---

<div class="post-metadata">

**Author:** ![anon70733690](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@anon70733690](https://forum.ionicframework.com/u/anon70733690)\
**Post date:** [April 20, 2017, 12:11pm UTC](https://forum.ionicframework.com/t/ionic-2-unit-tests-with-webpack-or-angular-cli/87165/3 "2017-04-20T12:11:41Z")

</div>

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

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

```

vs as can be seen in the community:

```auto
      preprocessors: {
            './src/test.ts': ['@angular-cli']
        },

```

---

<div class="post-metadata">

**Author:** ![anon70733690](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@anon70733690](https://forum.ionicframework.com/u/anon70733690)\
**Post date:** [April 25, 2017, 2:08pm UTC](https://forum.ionicframework.com/t/ionic-2-unit-tests-with-webpack-or-angular-cli/87165/5 "2017-04-25T14:08:51Z")

</div>

We moved to

```auto
    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:

> **[lathonez/clicker](https://github.com/lathonez/clicker)**
>
> clicker - Ionic 2 + @angular/cli Seed Project : Angular2 + Typescript + Karma + Protractor + Travis

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.
