Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of Jasmine tests not showing in browser output when running `ng test`

I inherited an Angular app that was first worked on a couple of years ago. One of the tasks I've been given is to get our testing going - as tests haven't been run over the last year or more. This was originally an Angular 2 app, and has been updated to be around 2.3.1. At the moment we can't do a further update because it would involve substantial refactoring that we need to tackle at a later time.

Here's the issue, when I run ng test it does generate some initial tests. However, when the browser window opens, while I see the Karma details, showing Karma v1.20 - connected (see pic), I don't see any of the listing of actual files that are failing or passing via Jasmine.

enter image description here

It's like the Jasmine portion has been disabled. Or hidden from showing here? Not sure. This is what I would expect to see (screenshot from another app's test results):

enter image description here

FYI, in the command line I see the tests have run (all are passing):

04 04 2019 13:14:48.834:INFO [karma]: Karma v1.2.0 server started at http://localhost:9876/
04 04 2019 13:14:48.836:INFO [launcher]: Launching browser Chrome with unlimited concurrency
04 04 2019 13:14:48.851:INFO [launcher]: Starting browser Chrome
04 04 2019 13:15:15.529:WARN [karma]: No captured browser, open http://localhost:9876/    
Chrome 73.0.3683 (Mac OS X 10.14.4): Executed 5 of 5 SUCCESS (0.199 secs / 0.188 secs)

I have searched through various files, but so far have been unable to find a portion of Jasmine code that's been disabled or commented-out. So how can I go about finding how to re-enable the Jasmine printout as part of my test run? Can I uninstall and reinstall just a testing package? What's recommended in a situation like this?

I'm also wondering if it could be a problem with my karma.conf.js file. This is what mine looks like:

// Karma configuration file, see link for more information
// https://karma-runner.github.io/0.13/config/configuration-file.html

    module.exports = function (config) {
      config.set({
        basePath: '',
        frameworks: ['jasmine', '@angular/cli'],
        plugins: [
          require('karma-jasmine'),
          require('karma-chrome-launcher'),
          require('karma-jasmine-html-reporter'),
          require('karma-remap-istanbul'),
          require('@angular/cli/plugins/karma')
        ],
        files: [
          { pattern: './src/test.ts', watched: false }
        ],
        preprocessors: {
          './src/test.ts': ['@angular/cli']
        },
        mime: {
          'text/x-typescript': ['ts','tsx']
        },
        remapIstanbulReporter: {
          reports: {
            html: 'coverage',
            lcovonly: './coverage/coverage.lcov'
          }
        },
        angularCli: {
          config: './angular-cli.json',
          environment: 'dev'
        },
        reporters: config.angularCli && config.angularCli.codeCoverage
                  ? ['progress', 'karma-remap-istanbul']
                  : ['progress'],
        port: 9876,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['Chrome'],
        singleRun: false
      });
    };
like image 663
Muirik Avatar asked Sep 02 '25 07:09

Muirik


1 Answers

try to add the following lines to the karma.conf.js

client: {
    clearContext: false
}
like image 188
pharfe Avatar answered Sep 05 '25 00:09

pharfe