coen.bakker

coen.bakker

When to use feature tests? Have I been overusing Wallaby?

I have recently started using TDD for Phoenix/LiveView. I read the tddphoenix.com course and really liked this approach to building features. Following the example on tddphoenix.com, I have been using Wallaby for my feature tests.

However, when I look around in open source LiveView projects, I see that they don’t use feature tests. At least the open source projects that I have looked into. I feel like I’m missing something here. I have a ton of feature tests already. Could that be a bad thing?

If you’re also using TDD, when would you recommend using a feature testing package, like Wallaby? What are the arguments for and against? If you are using TDD, but not feature tests, how are you approaching TDD in your projects?

Most Liked

mhanberg

mhanberg

Expert LSP Core Team

Current maintainer of Wallaby here :waving_hand:

If your LiveViews aren’t using any JS hooks, then using LiveViewTest is a reasonable first stop when testing a LiveView. I almost think of it as unit testing your LiveView.

I think some differences to note when making a decision:

  • LiveViewTests test a single LiveView. Wallaby tests test from the outside in, and manage tests that that cross the page boundary (where a different LiveView or controller will be rendered)
  • LiveViewTest is faster, but aren’t tested in a real browser.

I think they both have their place, but in generally you might have more LiveViewTest than Wallaby tests, as they are cheaper to run.

I have plans (I am currently very busy with #elixir-tools, but some day hopefully) to implement a LiveViewTest driver for Wallaby, so that you can write LiveViewTest with the Wallaby API: LiveViewTest Driver · Issue #729 · elixir-wallaby/wallaby · GitHub

sodapopcan

sodapopcan

I have not read the book you referenced (though I’d like to!) so I have no frame of reference there.

I do write feature tests (or e2e’s as I call 'em) and while I am a big fan of top-down (which is sounds like your are doing) I draw the line at starting with them because they are too heavy. The primary point of going top down for me is to inform what I need to build (as well as not to have to write tests afterwards which is never fun), and starting with LiveView and controller tests takes care of this just fine (while also providing good regression coverage!) I write feature specs afterwards to cover things that can’t be covered by the other methods (mostly JS stuff) as well as providing “smoke tests.” And sometimes user journey-type stuff, though I’ve been doing some of that in LiveView tests lately! I don’t like having lots of features specs since they are slow and, even though they are much faster in Elixir world, I like to keep them sparse and only test the happy paths.

In a world where feature specs ran as quickly as LiveView tests, they very well may be the only tests I would write :slight_smile: That’s not totally true, but sort of.

Where Next?

Popular in Questions Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
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
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> somethi...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
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
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Other popular topics Top

ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
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
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31142 143
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
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

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement