elixir-wallaby / wallaby

Concurrent browser tests for your Elixir web apps.
https://twitter.com/elixir_wallaby
MIT License
1.68k stars 198 forks source link

[request] Option to output errors if some resource fails to be loaded #545

Open miquecg opened 4 years ago

miquecg commented 4 years ago

Issue

I have a proposal in case is not contemplated yet. I've run into an issue on CI that didn't happen on my local dev environment. It turned out to be completely my fault but maybe wallaby could have give some extra information.

One feature test was failing to find elements that in fact were there. As I've said, everything was running fine on my machine™ so this was odd, until I've realized what the problem was.

Those elements are empty <div> that are converted to grid elements after applying some CSS, so in case of a missing stylesheet those elements will not be visible at all, and I forgot to build the assets with webpack on CI environment, so no styles were applied.

If wallaby had complained or at least warned about that 404 error when loading the CSS resource, I'd had a hint pointing in the right direction.

Having an option to make wallaby output network errors after loading a page would be helpful in similar scenarios.

Test Code & HTML

defmodule HeroesWeb.AcceptanceTest do
  use HeroesWeb.BrowserCase, async: true
  @moduletag :browser

  import Wallaby.Query, only: [css: 2]

  @game game_path(@endpoint, :index)

  feature "When a browser opens the game endpoint the board grid is loaded", %{session: session} do
    Application.put_env(:heroes_server, :board, GameBoards.Oblivion)

    session
    |> visit(@game)
    |> assert_has(css("#grid .cell", count: 48))
    |> assert_has(css(".cell.wall", count: 7))
  end
end
<section>
  <h1>Heroes Board Game</h1>
  <div id="grid">
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell"></div>
    <div class="cell wall"></div>
    <div class="cell"></div>
    <!-- and so on ... -->
</section>
mhanberg commented 4 years ago

Thanks for taking the time to open an issue 😄.

I'll take a look at the WebDriver spec to see if there is anything built in for this.