     assert conn.resp_body =~ "CompileError"
     assert conn.resp_body =~ "Compilation error"
   end
+
+  defp wait_until_is_up(process) do
+    if Process.whereis(process) do
+      :ok
+    else
+      Process.sleep(10)
+      wait_until_is_up(process)
+    end
+  end
 end

  test "syncs with code server" do
    assert Phoenix.CodeReloader.Server.sync == :ok

    # Even in case of crashes, it works.
    :sys.suspend(Phoenix.CodeReloader.Server)

    Task.start_link(fn ->
      Phoenix.CodeReloader.Server

    end)

    assert Phoenix.CodeReloader.Server.sync == :ok
    assert_receive {:DOWN, ^ref, _, _, _}
    wait_until_is_up(Phoenix.CodeReloader.Server)
  end

  test "reloads on every request" do
