Search code examples
angularunit-testingjasminekarma-jasminetestbed

Display issue without css with ng test Angular 4 Karma-Jasmine


I have display issue when running the command ng test. It seems I don't have css effect anymore.Here are two images one from the ng serve and the other from ng test enter image description here

enter image description here Is this a normal behavior ? Should I share specific files from my project Just leave a comment.


Solution

  • This might be too late but it may help somebody.

    Go to your karma.conf.js and add this

    module.exports = function (config) {
      config.set({
        basePath: '',
        frameworks: ['jasmine', '@angular/cli'],
        files:[
          "node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
         "src/styles.css",
        ],
         // more code below
    

    In this sample, I added my styles.css and a pre-built theme from angular material.

    Let me know if you still need any help.