Home > Back-end >  Is there a simple way to find slow specs
Is there a simple way to find slow specs

Time:09-21

When running all specs in a project I have not touched in a while, I noticed that there seem to be 2 specs that take ages. I suspect some mocking of an API call or similar is not working anymore and the specs are running into a timeout.

Is there an easy way to identify those 2 specs without going manually through all spec files?

CodePudding user response:

You can enable profiling by using the -p flag when running rspec

Or you can permanently enable profiling by adding

config.profile_examples = true

or, for example,

config.profile_examples = 5

to your Rspec configuration in spec/spec_helper.rb.

By default, it prints the 10 slowest examples, but you can set it to a different value to have it print more or fewer slow examples.

  • Related