wallaby
wallaby copied to clipboard
Wallaby.Browser.visit/2 does not generate an error if server is unreachable
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.