jeudi 28 février 2019

How to run karma tests in Angular when stylus stylesheets are used?

I'm not sure whether I constructed the question title right. I want to run tests for my Angular 7 application by using ng test. In one of my component I have a Stylus stylesheet used:

@Component({
  selector: 'app-root',
  template: ``,
  encapsulation: ViewEncapsulation.None,
  styleUrls: ['../../../../src/app/globalNg1Styles.styl']
})

It works fine when I serve the application but I have this error when I try to run the tests:

ERROR in (...)/src/app/globalNg1Styles.styl
Module build failed (from (...)node_modules/stylus-loader/index.js):
TypeError: Cannot read property 'stylus' of undefined at Object.module.exports ((...)node_modules/stylus-loader/index.js:29:33)
 @ ./src/app/catalog.component.ts 18:21-72
 @ ./src/app/catalog.component.spec.ts
 @ ./src sync \.spec\.ts$
 @ ./src/test.ts

I don't get what's wrong and how can I solve the problem.

Aucun commentaire:

Enregistrer un commentaire