The issue is most likely relate to the builder. If you're using @angular-devkit/build-angular which is the old builder, it doesn't allow you to use the loader in the karma build. To solve it install @angular/build and update your angular.json accordingly.