So you have this nice Jasmine suite that's very useful and maybe even proud of...but it takes over a minute to run? It seems to get stuck at one or a few specs but you can't figure out which one? I had that exact problem this morning while working on my SaaS, Metrics Watch (near real-time alerts for Google Analytics).

Let me help you!

Add this helper:

// This works under Jasmine 2.3varslowSpecsReporter={specStarted:function(result){this.specStartTime=Date.now()},specDone:function(result){varseconds=(Date.now()-this.specStartTime)/1000if(seconds>0.5){console.log('WARNING - This spec took '+seconds+' seconds: "'+result.fullName+'"')}},}jasmine.getEnv().addReporter(slowSpecsReporter);

In my case, I am using jasmine-rails, so to have this helper running I had to create a file named specs/javascripts/support/jasmine-slow-spec-reporter.js and edit the jasmine.yml so it looks more like this:

Now you'll get console outputs on slow spec with the full name of the spec, you can now find out those slow specs and get your suite to run in less than 5 seconds instead of over a minute!

That's the easy part though, the hard part is usually to figure out WHY your specs are slow, at least, in my case it was not that obvious. Want to know how I made it faster? Subscribe to my email list (the box at the bottom right) and I'll let you know how I did for my React & Redux project soon! You don't want to figure it out and need a hand now speeding up your test suites (Javascript or Ruby)? Hire me ;)