templateUrl is not loading in Angular2 unit Testing with karma and Jasmin, but template is working, I don't want to put html in my component files so I'm using templateUrl.
I found this https://github.com/sjelin/karma-redirect-preprocessor and altered the karma.config file but it doesn't seem to be working.
Please let me know if anyone has complete example for this.
There are a few known issues with testing components that use templateUrl
If you are using webpack
1.Run npm install raw-loader --save
2.Instead of templateUrl:'./template.html'
use template: require('raw!./templat.html)
I modified the value of appAssets to have a leading slash in karma.config.js.
var appAssets = '/base/app/';
...
proxies: {
"/app/": appAssets
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.