Posted 9 months ago. Visible to the public. Repeats.

Ensure passing Jasmine specs from your Ruby E2E tests

Jasmine Archive is a great way to unit test your JavaScript components without writing an expensive end-to-end test for every small requirement.

After we integrated Jasmine into a Rails app we often add an E2E test that opens that Jasmine runner and expects all specs to pass. This way we see Jasmine failures in our regular test runs.


In a feature spec Archive you can run Jasmine specs like this:

scenario 'Jasmine tests' do visit test_jasmine_path expect(page).to have_content('finished in') # wait for all tests to finish expect(page).not_to have_css('.jasmine-failed .jasmine-description') # better error messages expect(page).to have_css('.jasmine-bar.jasmine-passed') # safer check end


In Cucumber you can run Jasmine specs like this:

Scenario: Jasmine tests When I run Jasmine tests Then all specs should have passed
When 'I run Jasmine tests' do visit test_jasmine_path end Then 'all specs should have passed' do expect(page).to have_css('.jasmine-version'), 'Failed to load Jasmine page' using_wait_time 60 do expect(page).to have_content('finished in') # patiently wait for all tests to finish end # The above check will wait until tests are finished; once they are, we want # to show fails early using_wait_time 0 do failed_specs = page.all('.jasmine-failed .jasmine-description').map(&:text) puts 'Failed Jasmine specs:' if failed_specs.any? failed_specs.each do |description| puts "* #{description}" end expect(failed_specs.size).to eq(0), "Some Jasmine Specs failed (see above)" expect(page).to have_css('.jasmine-bar.jasmine-passed') # safer check end end

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for unsupported versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2).

Owner of this card:

Henning Koch
Last edit:
8 months ago
by Klaus Weidinger
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Henning Koch to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more