We've been stumped trying to figure out how to get Selenium JavaScript testing working with our Dockerised Ruby (Hanami) app. For spec examples that don't depend on JavaScript, of course, the Capybara-default Rack::Test driver is adequate, but every modern app depends on JavaScript for one thing or another, and ours is/will be no different.
I've read a few of the answers here on SO, and started rifling through GitHub looking for random similar projects, but we've been stopped for an increasingly politically unsustainable length of time here.
To summarise:
- We can run JavaScript-using feature specs successfully if no non-JS specs are run in the same
rake
invocation. (We usejbodah/minitest-tagz
to filter spec invocations); - When running our full set of specs, Firefox Marionette hangs when running a JavaScript-enabled example, with its log message indicating that it does not have the IP address it should be connecting to.
We've only found a very limited set of tutorials/walkthroughs that are obviously applicable, mostly quite long in the tooth by 2018. The two that we've cargo-culted most blatantly are
- Integration testing with dockerized Selenium and Capybara, by Ahmet Kizilay in February 2016; and
- Dockerized Rails Capybara tests on top of Selenium, by Alfredo Motta in May, 2016.
It's probable, or at least likely, that we've consistently misread or glossed over something in these that is biting us now. It's also worth noting that Docker internals, particularly related to networking, seem to have evolved significantly in the last two years, and that may have something to do with our problem.
I've included copies of the following files in a Gist, since they're too much in aggregate to paste here:
00-Capybara-Selenium-Docker-confusion__readme.md
: this problem statement;01-docker-compose.yml
: thedocker-compose.yml
file for the application;02-run_tests.sh
: thescripts/run_tests.sh
file which serves as thecommand
run by theweb
container as specified in thedocker-compose
file;03-features_helper.rb
: the `spec/features_helper' required by each feature spec; primarily concerned with Selenium setup;04-Dockerfile
: theDockerfile
used to build theweb
container;05-join_as_member_spec.rb
: one of the feature specs which exercises JavaScript in the application;06-focused_logfile.log
: the terminal output from runningdocker-compose up --exit-code-from web
with only JavaScript-exercising spec examples being run;07-unfocused_logfile.log
: the terminal output from running the samedocker-compose
invocation with all examples in all specs enabled (i.e., not limited through the use oftag :focus
).
Any helpful comments and/or pointers to existing working test setups (regardless of framework being used, e.g., Rails) would be greatly appreciated. Thanks.