I'm new to Elixir/Phoenix so I'm not sure if this is working as expected or an issue I should address.
I have a Phoenix app that I just started adding integration tests to. Having done this for a few days of setting up and testing the User registration feature, I'm now onto testing the login.
I'm using Wallaby:
test.exs:
config :happy_app, :sql_sandbox, true
config :wallaby,
driver: Wallaby.Experimental.Chrome,
chrome: [headless: true],
screenshot_on_failure: true
test_helper.exs:
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(HappyApp.Repo, :manual)
{:ok, _} = Application.ensure_all_started(:wallaby)
Application.put_env(:wallaby, :base_url, HappyAppWeb.Endpoint.url())
My test looks like this:
defmodule HappyAppWeb.UserLoginTest do
use HappyAppWeb.IntegrationCase, async: true
alias HappyApp.Accounts
import HappyAppWeb.IntegrationSteps
@tag integration: true
test "user can login", %{session: session} do
email = "test-user@example.com"
password = "12345678"
# seed user into db
user = Accounts.create_user(%{email: email, password: password})
IO.inspect user
# logging in with the user's email and password
# asserting the view is correct
end
end
When I inspect the user: IO.inspect user
I get:
IO.inspect user
=>
{:ok,
%HappyApp.Accounts.User{
__meta__: #Ecto.Schema.Metadata<:loaded, "users">,
email: "test-user@example.com",
id: 449,
inserted_at: ~N[2019-11-24 13:20:33],
password: nil,
password_hash: "shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh",
updated_at: ~N[2019-11-24 13:20:33]
}}
Notice the id: 449,
. Is that correct? Shouldn't that reset between tests back to 1?
Manually looking into postgres I see that happy_app_test db is indeed empty. Is the data elsewhere?