unit-tests karma-runner/jasmine profiling

前端 未结 3 820
既然无缘
既然无缘 2020-12-24 08:37

For unit-tests we use grunt/karma-runner/jasmine/phantom.js. Because we try to cover any new functionality, a number of unit-tests grows up rapidly. And, unfortunately, time

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-24 08:59

    1a) About profiling: you can use karma reporters, add to your karma-config this strings:

        reporters: [
            'progress',
            'junit',
        ],
        junitReporter: {
            outputFile: basePath + 'test_out/unit.xml',
            suite: 'unit'
        },
    

    it will produce nice xml like this:

    
    
    

    And you can sort and choose which slowest test should be optimized

    1b) Also you can use reportSlowerThan from karma config

         reportSlowerThan: 100,
    

    Karma will inform you about tests slower than 100ms

    2) I don't know how to start more karma-runner processes/threads.

    3) because grunt:watch provide you changed filename.js, you can start corresponding filename.spec.js, so you have to write special grunt-task

    and use ddescribe and iit to start only specified describe/it.

提交回复
热议问题