Two or three weeks ago I deployed first version of erlangjobs.ru web site - Elixir/Erlang free job board.
Today we have team of three core developers, and one of them helped us with elixirjobs.ru domain. Many thanks!
So, we implemented beautiful slugs for job urls, new main page, twitter posts and many other code and feature improvements.
Few days go, I decided to implement integrations tests into our project.
Just setup Hound on your project:
def deps do
[{:hound, "~> 1.0"}]
end
Add Hound to your test/test_helper.exs file before the ExUnit.start() line:
Application.ensure_all_started(:hound)
ExUnit.start()
Install and run webdriver server. I choosed chromedriver (macOS with homebrew):
brew install chromedriver
And one more thing. Add webdriver into your config:
config :hound, driver: "chrome_driver"
Last step - add the following lines to your ExUnit test files:
use Hound.Helpers
hound_session()
Write new test:
defmodule Erlangjobs.NewJobTest do
use Erlangjobs.IntegrationCase
def jobs_index do
job_url(ErlangjobsWeb.Endpoint, :index)
end
@tag :integration
test "GET /jobs/new and add invalid job" do
jobs_index() |> navigate_to()
click({:id, "add_job"})
assert element_displayed?({:id, "add_job_form"})
new_job_form = find_element(:id, "add_job_form")
new_job_form
|> find_within_element(:id, "job_title")
|> fill_field("New Job")
new_job_form
|> find_within_element(:css, "button")
|> click
assert element_displayed?({:css, ".alert.alert-danger"})
end
end
Run your tests as usual:
mix test