简体   繁体   中英

How to get unit test logs ? Browser closes after tests are run

My .NET application works with Angular & we use Jasmine framework to test User interface.

Karma is being run to launch UI tests.

While on development phase, I launch it via command prompt by running karma start

Now,

  1. How do I see the logs of the testing ?
  2. The browser closes even before I press debug button so debugging is quite impossible for us to do. How to make Karma wait ?

Any help would be appreciated. Just started with angularJS, sorry if above questions are too naive, but already spent a while understanding this.

You have karma's single run enabled.

In your karma.config.js change singleRun to false

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

Full file:

module.exports = function(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
        // angular-filesort sorts angular dependencies upon injection to prevent
        // angular constants loading before angular itself
        frameworks: ['bower', 'jasmine', 'angular-filesort'],

        // list of files / patterns to load in the browser
        files: gulpConfig.karma.files,


        // list of files to exclude
        exclude: gulpConfig.karma.exclude,


        // preprocess matching files before serving them to the browser
        // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
        preprocessors: {

        },


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

        // 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', 'PhantomJS'],


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

        // Concurrency level
        // how many browser should be started simultaneous
        concurrency: Infinity
    });
}

Note:

To exit continuous run just use the good old Ctrl+c

Also get some sort of reporter so that you can see what's happening from the prompt.

Here is a list of available reporters.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM