joshamb
When to use LiveViewTest vs Playwright
LiveView uses Playwright for e2e testing, whilst also shipping with LiveViewTest
They both have there pros, but the biggest ones (to me) are:
- Playwight - codegen (the ability to interactively create your tests in the browser very quickly)
- LiveViewTest - (is probably) a lot quicker to run a significant amount of tests & native integration for component testing
I was wondering how other people decide when to use which one, or if they only use either Playwight or LiveViewTest (or another!).
From how I see it, LiveViewTest has the advantage of it being able to do both component and e2e tests, however it’s much quicker (for a developer) to make e2e tests in Playwright.
Marked As Solved
axelson
To me the biggest consideration is that if you need to execute your js hooks then you’ll need a full e2e runner like Playwright or Wallaby since LiveViewTest runs only the Elixir code.
Also Liked
LostKobrakai
There’s currently work happening on phoenix_test to make playwright another driver for it, so switching to it would become a config switch.
fteschke
Here’s the mentioned Playwright driver for PhoenixTest:
defmodule Features.RegisterTest do
use PhoenixTest.Playwright.Case
@tag trace: :open # replay in interactive viewer
test "register", %{conn: conn} do
conn
|> visit(~p"/")
|> click_link("Register")
|> fill_in("Email", with: "f@ftes.de")
|> click_button("Create an account")
|> assert_has(".text-rose-600", text: "required")
end
end
D4no0
For e2e tests, there is also Wallaby.
It’s all about whether you want a battery-included solution or you are OK with doing/maintaining a part of the setup yourself. LiveViewTest as you mentioned is a unified tool for all your phoenix test needs, it requires zero setup if you have a phoenix project, but at the same time it’s obviously not as flexible as using the dependency directly.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








