3

I am trying to write some integration tests in rspec/capybara/selenium for my Rails 5 app. I have recently started testing some javascript features in the app with headless Chrome.

I struck a problem where I was unable to choose a select element on the page with capybara despite this working fine when I loaded the site manually in chrome in development environment. After some investigating I figured out that the select element was not currently visible. It is hidden when the page loads but should then be made visible immediately on loading by my javascript.

I disabled headless and paused my test with a quick and dirty sleep 60. I then looked at the javascript file in Chrome's developer tools and discovered that it has loaded an old version of the file with none of my recent changes. The file it has loaded no longer exists in my app so it must be being cached somewhere. Any ideas how this might be occurring and how I can fix it?

brad
  • 9,573
  • 12
  • 62
  • 89
  • 1
    does https://stackoverflow.com/a/40441986/1033737 help? – fabdurso Jul 04 '17 at 09:42
  • Yes, that fixed it! Thankyou. Are you able to explain to me why this was necessary in my tests but not in my development environment? It looks like I don't understand the asset pipeline quite as well as I thought I did. – brad Jul 04 '17 at 11:13
  • 1
    From the linked answer: it's `rake assets:clobber`. That worked for me. – Jason Swett Apr 19 '19 at 17:26

0 Answers0