Answer the question
In order to leave comments, you need to log in
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.
In theory, I should see something like this:
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
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
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question