peck

peck

End To End Testing With Hound and Github-Actions

Hi all,

Does anyone have a working setup to do end to end testing using hound with github-actions?

I’ve got it working locally :roll_eyes:, and its a great way to sanity check the multi-step liveview features on this project but when running on the github-action I get a

** (RuntimeError) invalid element state for each of those tests.

When using hounds fill_field function.

I’ve tried several different combinations of things last night and this morning and seem to be at a deadend, and I’m unsure what else to try.

My workflow.yaml is below.

name: Master PR

on: 
  pull_request:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-18.04

    services:
      postgres:
        image: postgres:10.8
        env:
          POSTGRES_USER: postgres
          POSTGRES_PASSWORD: postgres
          POSTGRES_DB: larder_test
        ports:
        - 5432:5432
        # needed because the postgres container does not provide a healthcheck
        options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

    steps:
    - uses: actions/checkout@v1
    - uses: actions/setup-elixir@v1.1.0
      with:
        otp-version: 22.x
        elixir-version: 1.9.x
        
    - name: Install Dependencies
      run: |
        mix local.rebar --force
        mix local.hex --force
        mix deps.get


    - name: Setup Node
      uses: actions/setup-node@v1

    - name: Install ChromeDriver
      run: |
        CHROME_VERSION=$(google-chrome --version | cut -f 3 -d ' ' | cut -d '.' -f 1) \
          && CHROMEDRIVER_RELEASE=$(curl --location --fail --retry 3 http://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}) \
          && curl --silent --show-error --location --fail --retry 3 --output /tmp/chromedriver_linux64.zip "http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_RELEASE/chromedriver_linux64.zip" \
          && cd /tmp \
          && unzip chromedriver_linux64.zip \
          && rm -rf chromedriver_linux64.zip \
          && sudo mv chromedriver /usr/local/bin/chromedriver \
          && sudo chmod +x /usr/local/bin/chromedriver \
          && /usr/local/bin/chromedriver --version
          
    - name: Run Tests
      run: |
        export DISPLAY=:99
        /usr/local/bin/chromedriver --port=9515 &
        curl localhost:9515
        sudo xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
        mix compile 
        mix test
      env:
        # use postgres for the host here because we have specified a container for the job.
        # If we were running the job on the VM this would be localhost
        DB_USER: postgres
        DB_PASS: postgres
        DB_NAME: larder_test

My Hound config lines:

config :hound, driver: "chrome_driver", browser: "chrome_headless"

config :hound, app_host: "http://localhost", app_port: 4002

config :hound, retry_time: 500

Can anyone point me in the right direction?

Most Liked

PJUllrich

PJUllrich

Author of Building Table Views with Phoenix LiveView

I’m using Wallaby together with GitHub Actions.
It’s a bit tricky to set up, but this elixir.yml GitHub Actions workflow should get you going :slight_smile:

For setting up any Wallaby tests, I’m using this FeatureCase test helper:

For the rest, I simply followed the Setup Tutorial of Wallaby.

alanvardy

alanvardy

name: Phoenix - Cypress Acceptance Tests

on: push

jobs:
  test:
    runs-on: ubuntu-latest

    services:
      db:
        image: postgres:11
        ports: ['5432:5432']
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
    steps:
      - uses: actions/checkout@v1.0.0
      - uses: actions/cache@v1
        with:
          path: deps
          key: ${{ runner.os }}-mix-cypress-${{ hashFiles('**/mix.lock') }}
          restore-keys: |
            ${{ runner.os }}-mix-cypress-
      - uses: actions/cache@v1
        with:
          path: _build
          key: ${{ runner.os }}-build-cypress-${{ hashFiles('**/mix.lock') }}
          restore-keys: |
            ${{ runner.os }}-build-cypress-
      # - run: cp config/dev.secret.exs.example config/dev.secret.exs
      - uses: actions/setup-elixir@v1.0.0
        with:
          otp-version: 22.1
          elixir-version: 1.9.1
      - run: mix deps.get
      - run: npm install --prefix assets
      - run: npm run deploy --prefix assets
      - run: mix phx.digest
      - run: mix cypress.ci

I am using Cypress for my acceptance tests, and had to run a few extra commands to get the JavaScript running properly on CI. I suggest trying

      - run: npm install --prefix assets
      - run: npm run deploy --prefix ./assets
      - run: mix phx.digest

Right before your run your tests and see what happens. I have no idea what the internals of Hound look like, but hopefully this helps.

alanvardy

alanvardy

I have been really happy with Cypress, and recommend it as an option.

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New

We're in Beta

About us Mission Statement