October 2019
Intermediate to advanced
358 pages
8h 22m
English
As we’ve said, any code worth writing is code worth testing, and your views are no exception. As you saw in Chapter 3, Controllers, Phoenix templates are simply functions in a parent’s view module. You can test these functions like any other. In this section, you’ll see how to test views and templates in isolation.
Create a test/rumbl_web/views/video_view_test.exs and key this in:
| 1: | defmodule RumblWeb.VideoViewTest do |
| - | use RumblWeb.ConnCase, async: true |
| - | import Phoenix.View |
| - | |
| 5: | test "renders index.html", %{conn: conn} do |
| - | videos = [ |
| - | %Rumbl.Multimedia.Video{id: "1", title: "dogs"}, |
| - | %Rumbl.Multimedia.Video{ ... |
Read now
Unlock full access