We have two issues with wait_for_ajax.
page.evaluate_script sometimes evaluates to nil leading to NoMethodError: undefined method `zero?' for nil:NilClass (e.g. in discovery integration tests)
2) Doing endless loop for nothing burns CPU time, adding a small delay will actually improve performance of JS tests because other processes can be served by the same CPU core while waiting.