defmodule Test.Support.MockServer do @moduledoc """ A mock server for running tests against """ use Plug.Router plug(:match) plug(:dispatch) get "/" do conn |> put_resp_content_type("text/html") |> send_resp( 200, ~S""" Dummy Site

I am a website

""" ) end get "/app.js" do conn |> put_resp_content_type("application/javascript") |> send_resp( 200, ~S""" const input = document.querySelector("input"); const button = document.querySelector("button"); const complexOutput = document.getElementById("text-output"); const output = document.getElementById("test-output"); button.addEventListener("click", () => { output.innerHTML = "Dummy Text"; }); """ ) end match _ do conn |> put_resp_content_type("text/html") |> send_resp(404, "

Not found.

") end end