Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Karma Html Reporter reload test when I try to navigate through the HTML document

I'm trying to use Karma and Jasmine to test my Angular 7.2 application.
It works fine, except one thing : when I click on a test name, it's refreshing the page and re executing all the tests again. The same happen when there is a failure and I click to "Spec List". I though a click on the test name should redo only the clicked test(s) and "Spec List" click should only go to the list of Spec showing which are passing and which don't.

Any idea why ?

karma.conf.js :

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

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-istanbul-reporter'),
            require('@angular-devkit/build-angular/plugins/karma'),
            require('karma-mocha-reporter')
        ],
        client: {
            clearContext: false // leave Jasmine Spec Runner output visible in browser
        },
        coverageIstanbulReporter: {
            dir: require('path').join(__dirname, '../coverage/gts-ui-extensions-rc'),
            reports: ['html', 'lcovonly', 'text-summary'],
            fixWebpackSourcePaths: true
        },
        reporters: ['mocha', 'kjhtml'],
        port: 4300,
        colors: true,
        logLevel: config.LOG_INFO,
        autoWatch: true,
        browsers: ['Chrome'],
        singleRun: false,
        restartOnFileChange: true
    });
};

dev dependencies :

"devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "~7.3.8",
    "@angular/compiler": "^7.2.12",
    "@angular/compiler-cli": "~7.2.0",
    "@angular/language-service": "^7.2.12",
    "@types/jasmine": "^3.3.12",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^11.13.0",
    "codelyzer": "^5.0.0",
    "jasmine-core": "^3.4.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^4.0.1",
    "karma-chrome-launcher": "^2.2.0",
    "karma-coverage-istanbul-reporter": "^2.0.5",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "karma-mocha-reporter": "^2.2.5",
    "protractor": "^5.4.2",
    "ts-node": "^8.0.3",
    "tslint": "^5.15.0",
    "typescript": "3.1.1",
    "webpack": "^4.29.6"
  }
like image 746
Mattew Eon Avatar asked Apr 11 '19 06:04

Mattew Eon


1 Answers

Some script is redirecting the <a href='#'> </a> links to the home page, while by default nothing should happen.

This problem is being addressed here: jasmine issues 1775

See the changes made to this pull request: pull request 1807

A temporary solution would be to apply the pull request 1807 changes to this file: node_modules\karma-jasmine-html-reporter\src\lib\html.jasmine.reporter.js

like image 142
Alex Parloti Avatar answered Sep 27 '22 17:09

Alex Parloti