A
A
Alexey Kompanets2017-02-17 14:14:01
Angular
Alexey Kompanets, 2017-02-17 14:14:01

Why is the result not displayed in the browser when running tests on Angular2?

When I run "ng test" on the project, I see this.
b5de1806ee0e4aba99ad5b65e1765eb8.png
In theory, I should see something like this:
06a5fe4a40e54db4b90b00d8bf23dd2b.png
The console shows that all tests were completed successfully.
karma.cong.js

module.exports = function (config) {
  config.set({
    basePath: '',
    frameworks: ['jasmine', 'angular-cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-jasmine-html-reporter'),
      require('karma-chrome-launcher'),
      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', 'kjhtml'],
    port: 9876,
    colors: true,
    logLevel: config.LOG_DEBUG,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
  });
};

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Zuev, 2017-02-18
@yurzui

Because karma doesn't display jasmine test runner results by default.
Usually, the karma-jasmine-html-reporter reporter is used for this , which, as I see from your config, you tried to configure.
I'm sure you installed this package via
AND you probably have something flickering in your browser. And the main problem is most likely that karma clears the output after the scripts are executed. To avoid this, setting

client: {
  clearContext: false
}

https://gist.github.com/alexzuza/f26abad42e6a7658c...
PS somewhere in version `1.0.0-beta.32.x` this was added by default https://github.com/angular/angular-cli /pull/4567

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question