Read more

Debugging cucumber feature with javascript + firefox vnc

Emanuel
December 06, 2016Software engineer at makandra GmbH

We don't use VNC anymore and some of the mentioned geordi commands don't exist anymore

TL;DR Debugging problems with javascript errors in cucumber tests is sometimes easier in the browser. Run the test, stop at the problematic point (with Then pause from Spreewald Show archive.org snapshot 1.7+) and open VNC for Firefox.

Illustration book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
Read more Show archive.org snapshot

Features:


Given there is a cucumber scenario which looks like this (many of the steps are part of the spreewald gem Show archive.org snapshot ):

@javascript
Scenario: Autocomplete city for station

Given there is a city with the name "Munich"
  And there is a station with the name "Munich main train station"

When I go to the form for the station above
  And I fill "City" with "Mun"
  And I click on "Munich"
  And I press "Save"

Then I should see a success flash
  And I should be on the page for the station above
  And I should see "City Munich"

Lets say, the autocomplete is not working. It will fail, as there is no element with the text "Munich". When the screenshot doesn't help you, here is what you can do, to debug the problem in the browser.

Add this step to your step definitions (it is extracted from spreewald's internal steps):

Then(/^wait for a enter key stroke$/) do
  print 'Press enter to continue...'
  STDIN.getc
end

Change your Scenario:

@javascript
Scenario: Autocomplete city for station

Given there is a city with the name "Munich"
  And there is a station with the name "Munich main train station"

When I go to the form for the station above
  Then I wait for a enter key stroke
  And I fill "City" with "Mun"
  And I click on "Munich"
  And I press "Save"

Then I should see a success flash
  And I should be on the page for the station above
  And I should see "City Munich"

Open you vnc with geordi: geordi vnc

Now you can dig in deeper and figure out what's wrong with your autocomplete.

Posted by Emanuel to makandra dev (2016-12-06 08:34)