coen.bakker

coen.bakker

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?

Showing Posts 1 to 3

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.

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

:heart_eyes:

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews