Error Karma Test Upgrade angular 13
Tags: karma, testing, angular
Published: 2022-02-18 12:11:50

I made the migration of the angular from 11 to 12 and from 12-13.

The tests have stopped working, I used karma-coverage-istanbul-reporter, I have changed it has coverage.

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

const ChromeHeadlessNoSandbox = {
  base: 'ChromeHeadless',
  flags: [ '--no-sandbox' ]
};

module.exports = function(config) {
  config.set({
      basePath: '',
      frameworks: ['jasmine', '@angular-devkit/build-angular'],
      plugins: [
          require('karma-jasmine'),
          require('karma-chrome-launcher'),
          require('karma-jasmine-html-reporter'),
          require('karma-coverage'),
          //require('karma-coverage-istanbul-reporter'),
          require('karma-teamcity-reporter'),
          require('@angular-devkit/build-angular/plugins/karma')
      ],
      preprocessors: {
      },
      mime: {
          'text/x-typescript': [
              'ts',
              'tsx'
          ]
      },
      client: {
          jasmine: {
              random: false,
          },
          clearContext: false // leave Jasmine Spec Runner output visible in browser
      },
      coverageReporter: {
          dir: require('path').join(__dirname, 'coverage'),
          reports: ['html', 'lcovonly', 'teamcity'],
          fixWebpackSourcePaths: true,
          'report-config': {
              html: {
                  subdir: 'html'
              },
              lcovonly: {
                  subdir: 'lcov',
                  file: 'lcov.info'
              },
              cobertura: {
                  subdir: 'cobertura',
                  file: 'coverage.xml'
              }
          }
      },
      reporters: ['progress', 'kjhtml'],
      port: 8080,
      colors: true,
      logLevel: config.LOG_WARN,
      autoWatch: true,
      browsers: ['Chrome', 'ChromeHeadless', 'ChromeHeadlessNoSandbox'],
      customLaunchers: {
        ChromeHeadlessNoSandbox
      },
      singleRun: true,
      browserNoActivityTimeout: 60000,
      browserDisconnectTimeout: 60000,
      browserDisconnectTolerance: 10

  });
};

Execute ng test and show errors:

Chrome 98.0.4758.82 (Windows 10) ERROR
  Disconnected , because no message in 60000 ms.
18 02 2022 12:38:38.295:WARN [Chrome Headless 98.0.4758.82 (Windows 10)]: Disconnected (1 times) , because no message in 60000 ms.
Chrome Headless 98.0.4758.82 (Windows 10) ERROR
  Disconnected , because no message in 60000 ms.
18 02 2022 12:38:38.357:WARN [Chrome Headless 98.0.4758.82 (Windows 10)]: Disconnected (1 times) , because no message in 60000 ms.
Chrome Headless 98.0.4758.82 (Windows 10) ERROR
  Disconnected , because no message in 60000 ms.
18 02 2022 12:38:40.465:WARN [Chrome 98.0.4758.82 (Windows 10)]: Disconnected (1 times) , because no message in 60000 ms.
Chrome 98.0.4758.82 (Windows 10) ERROR
  Disconnected , because no message in 60000 ms.
18 02 2022 12:39:39.088:WARN [Chrome Headless 98.0.4758.82 (Windows 10)]: Disconnected (2 times) , because no message in 60000 ms.
Chrome Headless 98.0.4758.82 (Windows 10) ERROR
  Disconnected , because no message in 60000 ms.
18 02 2022 12:39:39.262:WARN [Chrome Headless 98.0.4758.82 (Windows 10)]: Disconnected (2 times) , because no message in 60000 ms.
Chrome Headless 98.0.4758.82 (Windows 10) ERROR
  Disconnected , because no message in 60000 ms.
18 02 2022 12:39:42.252:WARN [Chrome 98.0.4758.82 (Windows 10)]: Disconnected (2 times) , because no message in 60000 ms.
Chrome 98.0.4758.82 (Windows 10) ERROR
  Disconnected , because no message in 60000 ms.
18 02 2022 12:40:39.998:WARN [Chrome Headless 98.0.4758.82 (Windows 10)]: Disconnected (3 times) , because no message in 60000 ms.
Chrome Headless 98.0.4758.82 (Windows 10) ERROR
  Disconnected , because no message in 60000 ms.
18 02 2022 12:40:40.216:WARN [Chrome Headless 98.0.4758.82 (Windows 10)]: Disconnected (3 times) , because no message in 60000 ms.
Chrome Headless 98.0.4758.82 (Windows 10) ERROR
  Disconnected , because no message in 60000 ms.

Any suggestion. Thanks