Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wallaby.Browser.visit/2 does not generate an error if server is unreachable #524

Open
ngeraedts opened this issue Apr 3, 2020 · 0 comments

Comments

@ngeraedts
Copy link

Issue

If the page to be visited is unreachable, the valid/2 function does not raise an error, leading to some potentially misleading error messages down the code path.

Test Code & HTML

The following test case and error message were discovered because I had failed to follow instructions and set Phoenix's server: true in my config/test.exs file. PEBKAC. :)

Using the following test:

  test "view homepage", %{session: session} do
    cookies =
      session
      |> visit("/")
      |> set_cookie("foo", "bar")
      |> visit("/")
      |> Browser.cookies()
      |> hd()
    assert cookies["name"] == "foo"
    assert cookies["value"] == "bar"
  end

We get the following error message:

     ** (Wallaby.CookieError) The cookie you are trying to set has no domain.
     You're most likely seeing this error because you're trying to set a cookie before
     you have visited a page. You can fix this issue by calling `visit/1`
     before you call `set_cookie/3`.

It would be useful if the visit/2 call would generate an error indicating that the browser was unable to reach the desired page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant