Undefined function render_to_string when using Phoenix.Template with :phoenix, "~> 1.7.14" in tests

I am trying to migrate view tests from phoenix 1.6 to 1.7.

I am following this example:

This is the test:

And these are my deps:

I am getting the following errors:

Running ExUnit with seed: 263700, max_cases: 32

    error: undefined function render_to_string/3 (expected CopiWeb.ErrorHTMLTest to define such a function or for it to be imported, but none are available)
    │
  9 │     assert render_to_string(CopiWeb.ErrorHTML, "404.html", []) == "Not Found"
    │            ^^^^^^^^^^^^^^^^
    │
    └─ test/copi_web/controllers/error_html_test.exs:9:12: CopiWeb.ErrorHTMLTest."test renders 404.html"/1

    error: undefined function render_to_string/3 (expected CopiWeb.ErrorHTMLTest to define such a function or for it to be imported, but none are available)
    │
 13 │     assert render_to_string(CopiWeb.ErrorHTML, "500.html", []) == "Internal Server Error"
    │            ^^^^^^^^^^^^^^^^
    │
    └─ test/copi_web/controllers/error_html_test.exs:13:12: CopiWeb.ErrorHTMLTest."test renders 500.html"/1

I am running the tests like this:

mix test

The error happens on a clean windows machine (without previous deps) using elixir 1.18.3

You’re missing the format, which is a separate argument (render_to_string/4).

render_to_string(CopiWeb.ErrorHTML, "400", "html", [])
3 Likes