Jer on Rails

Jeremy Weiskotten on web development, startups, beer, and other stuff.


A Kick in the Sass: Making slow functional tests faster

We started using Sass a while ago for all new styles, and recently converted all of our CSS to Sass. We noticed that after the conversion to Sass our test suite was suddenly taking a lot longer to run, in the neighborhood of 50% longer. Specifically, our functional and integration tests were a lot slower.

It turns out that, out of the box, Sass updates the “compiled” stylesheets on every request unless you’re running in production mode. This is really handy in development when you’re making incremental edits in a .sass file and refreshing the browser to see the results, but it’s completely unnecessary when running tests since the .sass files aren’t changing while the tests are running, and chances are your functional tests aren’t dependent on any CSS files anyway.

To change this behavior in our test environment, we added the following to config/environments/test.rb:


Now Sass will only compile the stylesheets once (the first time one is needed), and our entire test suite is about 60% faster (YMMV).

Tags: , ,

Comments are closed.