I noticed that the whole suite of Jasmine tests started taking more time that I would like, but I'm not sure, which ones actually cause the delay. Is there a way to find that out without running each test individually?
The basic ConsoleReporter
only reports the time elapsed for all the tests, but if you look at the source code of it you will see it's quite easy to modify to add the elapsed time for each spec. Basically what you need to do is to log the time a spec start when the function reportSpecStarting
(that's just before a spec starts to run) is called and output the difference when the function reportSpecResults
(that's just after a spec has finished running).
So if you modified the ConsoleReporter
with this, it would output you the name of each specification with their elapsed time :
this.reportSpecStarting = function() {
this.specStartingTime = this.now();
};
this.reportSpecResults = function(spec) {
var results = spec.results();
print(results.description + " ");
if (results.skipped) {
yellowStar();
} else if (results.passed()) {
greenDot();
} else {
redF();
}
print(" (" + (this.now() - this.specStartingTime) + "ms)");
newline();
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With