Search code examples
javascriptangularjasminekarma-jasminekarma-coverage

Karma runtime for each test file


I am currently using karma and jasmine in my Angular project and I have noticed that some tests are slow. So, I'm looking for a solution/reporter that shows the execution time for each file.


Solution

    1. Do npm i --save-dev karma-time-stats-reporter (https://www.npmjs.com/package/karma-time-stats-reporter)

    2. In karma.conf.js, in plugins: [...], add the entry require('karma-time-stats-reporter')

    3. Add the timeStatsReporter config object as specified in the documentation of the link I sent you. You should get the time after each test and when all of your tests run, it will show which tests took longer than 500ms. You can play around with the configuration to specify your own.