Testing Server-Rendered HTML Applications
Testing server-rendered HTML endpoints is very similar to testing JSON endpoints, but the response is an HTML document instead of JSON. We’ll write tests for the user controller that handles the server-rendered HTML endpoints. Let’s start by looking at the controller code that we’ll be testing:
| defmodule NotSkullWeb.UserController do |
| use NotSkullWeb, :controller |
| |
| alias NotSkull.Accounts |
| alias NotSkull.Accounts.User |
| alias NotSkull.ExternalServices.Email |
| def new(conn, _params) do |
| user = User.create_changeset(%{}) |
| render(conn, "new.html", changeset: user) |
| end |
| |
| def create(conn, %{"user" ... |
Get Testing Elixir now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.