coen.bakker

coen.bakker

Creating IntegrationCase recommended over `use Wallaby.Feature`?

TLDR: Started using Wallaby. Running into some test bugs related to Ecto.Adapters.SQL.Sandbox. Wondering if making an IntegrationCase module is ill advised, or maybe even recommended? Asking because I feel like I can’t foresee all the ramifications well myself. It seems more difficult to know what SQL sandbox related things are happening when using use Wallaby.Feature.


I recently started using Wallaby for part of my tests. I am still digging through the documentation and setting up the first tests.

In the code examples of the documentation the Feature module is used in the tests (i.e., use Wallaby.Feature is declared at the top of a test). The documentation of the Feature module, however, also mentions the following.

If you don’t wish to use Wallaby.Feature in your test module, you can add the following code to configure Ecto and create a session.

setup tags do
  :ok = Ecto.Adapters.SQL.Sandbox.checkout(YourApp.Repo)

  unless tags[:async] do
    Ecto.Adapters.SQL.Sandbox.mode(YourApp.Repo, {:shared, self()})
  end

  metadata = Phoenix.Ecto.SQL.Sandbox.metadata_for(YourApp.Repo, self())
  {:ok, session} = Wallaby.start_session(metadata: metadata)

  {:ok, session: session}
end

As far as I can tell there is no such thing as a IntegrationCase (or whatever name) module in Wallaby, in contrast to Elixir/Phoenix having DataCase, ConnCase and ChannelCase.

I am debugging some test bugs related to how Ecto.Adapters.SQL.Sandbox is setup. I was thinking that having a IntegrationCase would maybe be helpful in that process, because it seems more difficult to know what SQL sandbox related things are happening when doing use Wallaby.Feature.

Is it ill advised for me to make use of an IntegrationCase, rather than declaring use Feature in my test files? I did come across a mention of “IntegrationCase” in this 2017 article by Jake Worth. That’s some time ago, however, so I wanted to check what the status quo is.

Most Liked

krasenyp

krasenyp

It would be helpful to share what are the bugs you’re encountering. Without this context, I don’t really understand the question and can’t help. Maybe you can check German Velasco’s book about testing Phoenix - https://www.tddphoenix.com/, it uses Wallaby.

mhanberg

mhanberg

Expert LSP Core Team

If you want proper screenshots on failure, you’ll still want to use the feature macro by importing Wallaby.Feature

Where Next?

Popular in Questions Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30877 112
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement