ionic-team / ionic-unit-testing-example

Example of adding unit testing in your Ionic 2.x or greater apps with Karma and Jasmine
Other
374 stars 145 forks source link

Issues with image in html #53

Closed qiluo closed 6 years ago

qiluo commented 7 years ago

I've set up my test exactly like this example repo, everything worked properly until I added an image element into html, e.g.

<ion-row>
      <img style="height:16px; width:16px" src="assets/icon/star-16.png" *ngFor="let star of item.stars" />
 </ion-row>

When npm run test, always got

ERROR in ./src/pages/home/home.html
Module not found: Error: Can't resolve './assets/icon/star-16.png' in '/Users/xxx/Dev/ionic-apps/my-app/src/pages/home'
 @ ./src/pages/home/home.html 1:2111-2147
 @ ./src/pages/home/home.ts
 ...
 @ ./src/app/app.component.ts
 @ ./src/app/app.component.spec.ts
 @ ./src \.spec\.ts
 @ ./test-config/karma-test-shim.js
webpack: Failed to compile.

I'm new to Karma and Webpack, any idea?