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?


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.


Current maintainer of Wallaby here :wave:

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