简体   繁体   English

如何获得单元测试日志? 测试运行后浏览器关闭

[英]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. 我的.NET应用程序可与Angular使用,我们使用Jasmine框架来测试用户界面。

Karma is being run to launch UI tests. Karma正在运行以启动UI测试。

While on development phase, I launch it via command prompt by running karma start 在开发阶段,我通过运行karma start通过command prompt启动它

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. 浏览器甚至在我按下debug按钮之前就关闭了,因此我们几乎无法进行调试。 How to make Karma wait ? 如何让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. 刚开始使用angularJS,很抱歉,如果以上问题太幼稚,但已经花了一段时间来理解这一点。

You have karma's single run enabled. 您已启用业力的单次运行

In your karma.config.js change singleRun to false 在您的karma.config.js改变singleRun

    // 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 要退出连续运行,只需使用旧的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. 是可用的记者列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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