Troubleshooting Feature Specs
or how I learned about Database Cleaner
Closeup Brooms by OpenRoadPR is licensed under the Creative Commons Zero Licence
Adding the first couple of feature tests to a codebase can be tricky. You often know what you want to test and how you want to test it, but keep running into problems because you need to complete all of the setup.
While recently working in a new codebase, adding our first feature tests, I kept getting a failing test. The failure stated
Capybara::ElementNotFound: Unable to find option "option 1". In our case, that meant the test couldn’t select an option from a dropdown. I spent some time investigating with
save_and_open_page as well as
save_and_open_screenshot and found that the dropdown was being created, but there were no options in it.
To troubleshoot this, I:
- Checked factories
- Checked test setup
- Messed with drivers
- Googled all sorts of word concoctions related to the idea of “dropdown options not appearing in feature test”.