A sample repo showcasing PhoenixTest tests.
The code in the project was created with Phoenix generators.
The users
resources use regular (non-liveview) pages and controllers. The code
was generated with:
mix phx.gen.html Accounts User users name:string age:integer active_at:datetime
The posts
resources use LiveView. The code was generated with:
mix phx.gen.live Timeline Post posts body:string draft:boolean published_date:date
We created counterpart tests to showcase how equivalent tests would look with PhoenixTest.
The comparison isn't 1-1 since controller tests cannot test interactivity but PhoenixTests can. That's just one of the things that makes PhoenixTest so great!
Generated | PhoenixTest counterpart |
---|---|
UserControllerTest | AccountManagementTest |
PostLiveTest | TimelinePostsTest |
You can run all the tests with mix test