development icon indicating copy to clipboard operation
development copied to clipboard

Executing feature specs non-headless

Open hupf opened this issue 5 years ago • 2 comments

To debug or write feature specs, it is absolutely necessary to execute them in a non-headless browser. Generally, to do this, the HEADLESS=false environment variable can be set. With the current container setup it is not possible to execute the features specs in this mode – a solution has to be engineered and documented.

Work around:

  • Start database/rails server with Docker Compose.
  • On the local machine (not within a container!), from the core directory app/hitobito, use the following command to execute one or more feature specs in non-headless mode (Ruby/Bundler must be available, Gems installed):
RAILS_HOST_NAME=localhost:3000 RAILS_DB_ADAPTER=mysql2 RAILS_DB_HOST=127.0.0.1 RAILS_DB_PORT=33066 RAILS_DB_USERNAME=root RAILS_DB_PASSWORD=hitobito RAILS_DB_NAME=hitobito_test HEADLESS=false bundle exec rspec --tag type:feature spec/features/

See also #7

hupf avatar Aug 25 '20 13:08 hupf

I have previously had success with sharing the X socket with a container, such that the container can open windows on the host. On Linux and Mac OS, this can be done as follows:

  1. If you are on Mac, install the XQuartz X11 server (brew cask install xquartz) and restart your machine
  2. Run xhost local:root in order to allow the root user from the Docker container to send messages to the X server
  3. Configure the service that should open the windows as follows in docker-compose.yml:
    environment:
      - DISPLAY
    volumes:
      - /tmp/.X11-unix:/tmp/.X11-unix:rw
  1. docker-compose up

I have not tested this with the hitobito development repo yet, so far this is just for later reference when we take a look at solving this issue.

carlobeltrame avatar Aug 25 '20 15:08 carlobeltrame

I added the DISPLAY var and the volume from @carlobeltrame post. chromium now starts, but the opened window is just blank and I can't see any content. also the specs are failing when running with HEADLESS=false

further engineering is required ...

mtnstar avatar Sep 09 '20 12:09 mtnstar