Karma: Karma launches and the Debug button works but it doesnt show results in the browser.

Created on 10 May 2018  路  3Comments  路  Source: karma-runner/karma

Expected behaviour

Actual behaviour

Environment Details

  • Karma version (output of karma --version):
  • Relevant part of your karma.config.js file

Steps to reproduce the behaviour

1.
2.
3.

All 3 comments

I am using jasmine and karma to test my angular 5 tests.
Here is my karma.conf.js file:
`const webpackConfig = require('../../../webpack/webpack.test.js');

const WATCH = process.argv.includes('--watch');

module.exports = (config) => {
config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: './',
    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine', 'intl-shim'],
    //plugins: ['karma-parallel'],
    /*parallelOptions: {
    executors: (Math.ceil(require('os').cpus().length / 2)),
    shardStrategy: 'round-robin'
},*/
    // client:{
    //  clearContext: false // leave Jasmine Spec Runner output visible in browser
    // },
    // list of files / patterns to load in the browser
    files: [
        'spec/entry.ts'
    ],
    // list of files to exclude
    exclude: [],

    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
        'spec/entry.ts': ['webpack', 'sourcemap']
    },


    webpack: webpackConfig(WATCH),

    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['dots', 'junit', 'progress', 'karma-remap-istanbul', 'notify'],

    junitReporter: {
        outputFile: '../../../../target/test-results/karma/TESTS-results.xml'
    },

    notifyReporter: {
        reportEachFailure: true, // Default: false, will notify on every failed sepc
        reportSuccess: true // Default: true, will notify when a suite was successful
    },


    remapIstanbulReporter: {
        reports: { // eslint-disable-line
            'lcovonly': 'target/test-results/coverage/report-lcov/lcov.info',
            'html': 'target/test-results/coverage',
            'text-summary': null
        }
    },

    // web server port
    port: 9876,

    // enable / disable colors in the output (reporters and logs)
    colors: true,

    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,

    // enable / disable watching file and executing tests whenever any file changes
     autoWatch: true,


    // start these browsers
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
    browsers: ['Chrome'],

    // Ensure all browsers can run tests written in .ts files
    mime: {
        'text/x-typescript': ['ts','tsx']
    },

    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
singleRun: false
});

};
`

The plugins are inserted in my package.json file:

"devDependencies": { "html-loader": "0.5.0", "html-webpack-plugin": "2.30.1", "jasmine-core": "2.7.0", "karma-jasmine-html-reporter": "^0.2.2", "karma": "1.7.1", "karma-chrome-launcher": "2.2.0", "karma-coverage": "1.1.1", "karma-intl-shim": "1.0.3", "karma-jasmine": "1.1.0", "karma-junit-reporter": "1.2.0", "karma-notify-reporter": "1.0.1", "karma-phantomjs-launcher": "1.0.4", "karma-remap-istanbul": "0.6.0", "karma-sourcemap-loader": "0.3.7", "karma-webpack": "2.0.4", "merge-jsons-webpack-plugin": "1.0.11", "phantomjs-prebuilt": "2.1.16", "protractor": "~5.3.1", "proxy-middleware": "0.15.0", "rimraf": "^2.6.2", "source-map": "0.6.1", "sourcemap-istanbul-instrumenter-loader": "0.2.0", "style-loader": "0.18.2", "to-string-loader": "1.1.5", "tslint": "5.5.0", "tslint-loader": "3.5.3", "typescript": "2.6.2", ...}
Is this an Angular issue??

This is an issue with the karma-jasmine-html-reporter, that is the plugin that should show results in the browser. Maybe angular interferes I don't know, but ask angular or karma-jasmine-html-reporter folks.

@ebacka just uncomment

    client:{
      clearContext: false // leave Jasmine Spec Runner output visible in browser
    },

and you will be good.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

macjohnny picture macjohnny  路  5Comments

anius picture anius  路  3Comments

jhildenbiddle picture jhildenbiddle  路  4Comments

mgol picture mgol  路  3Comments

joerideg picture joerideg  路  5Comments