Karma and Webpack: Module not found: Error: Can't resolve './assets/images/phone.svg'


#1

I am having an extremely hard time to get Unit Testing with Karma, Webpack and Ionic 3 to run. After moving through error after error related to Webpack I am now at this:


ERROR in ./src/+onboarding/onboarding-details/onboarding-details.component.html
Module not found: Error: Can't resolve './assets/images/phone.svg' in '/Users/tyrion/devel/saveup-mobile-front/src/+onboarding/onboarding-details'

I tried resolve extensions and module loaders in my webpack.test.js:

    module: {
        rules: [
             {
                 test: /\.(png|jpg|svg)$/,
                 loader: 'url-loader?limit=8192'
            },
    resolve: {
        extensions: ['.ts', '.js','.png','.svg']
    },

Tried:

npm install null-loader file-loader

No success. Please help.


#2

I had the same issue. This tutorial helped me to set up the testing infrastructure correctly:
http://lathonez.com/2017/ionic-2-unit-testing/