From 20ff98572dd7c018206b2d41f1b5be38894ff942 Mon Sep 17 00:00:00 2001 From: steve0hh Date: Tue, 16 Aug 2016 23:22:36 +0800 Subject: [PATCH 1/2] Bugfix for js_errors unable to be set to false --- lib/wallaby.ex | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/wallaby.ex b/lib/wallaby.ex index 922f7b18..b25dbfa5 100644 --- a/lib/wallaby.ex +++ b/lib/wallaby.ex @@ -48,13 +48,17 @@ defmodule Wallaby do end def js_errors? do - Application.get_env(:wallaby, :js_errors) || true + Application.get_env(:wallaby, :js_errors) + |> explicitly_set() end def phantomjs_path do Application.get_env(:wallaby, :phantomjs, "phantomjs") end + defp explicitly_set(:false), do: false + defp explicitly_set(_), do: true + defp poolboy_config do [name: {:local, @pool_name}, worker_module: Wallaby.Server, From 07105f7ec341266f8f6bc2d8fb82e9cd188948d4 Mon Sep 17 00:00:00 2001 From: Chris Keathley Date: Tue, 16 Aug 2016 11:43:59 -0400 Subject: [PATCH 2/2] Use Application.get_env default for js errors --- lib/wallaby.ex | 6 +----- test/wallaby/driver/configuration_test.exs | 14 ++++++++++++++ .../{driver_test.exs => driver/js_errors_test.exs} | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 test/wallaby/driver/configuration_test.exs rename test/wallaby/{driver_test.exs => driver/js_errors_test.exs} (95%) diff --git a/lib/wallaby.ex b/lib/wallaby.ex index b25dbfa5..41dbe1f3 100644 --- a/lib/wallaby.ex +++ b/lib/wallaby.ex @@ -48,17 +48,13 @@ defmodule Wallaby do end def js_errors? do - Application.get_env(:wallaby, :js_errors) - |> explicitly_set() + Application.get_env(:wallaby, :js_errors, true) end def phantomjs_path do Application.get_env(:wallaby, :phantomjs, "phantomjs") end - defp explicitly_set(:false), do: false - defp explicitly_set(_), do: true - defp poolboy_config do [name: {:local, @pool_name}, worker_module: Wallaby.Server, diff --git a/test/wallaby/driver/configuration_test.exs b/test/wallaby/driver/configuration_test.exs new file mode 100644 index 00000000..7a1df832 --- /dev/null +++ b/test/wallaby/driver/configuration_test.exs @@ -0,0 +1,14 @@ +defmodule Wallaby.Driver.ConfigurationTest do + use Wallaby.SessionCase, async: false + + test "js errors can be disabled", %{session: session, server: server} do + Application.put_env(:wallaby, :js_errors, false) + + session + |> visit(server.base_url <> "/errors.html") + |> click_on("Throw an Error") + |> assert + + Application.put_env(:wallaby, :js_errors, nil) + end +end diff --git a/test/wallaby/driver_test.exs b/test/wallaby/driver/js_errors_test.exs similarity index 95% rename from test/wallaby/driver_test.exs rename to test/wallaby/driver/js_errors_test.exs index 68af414b..265d04a4 100644 --- a/test/wallaby/driver_test.exs +++ b/test/wallaby/driver/js_errors_test.exs @@ -1,4 +1,4 @@ -defmodule Wallaby.DriverTest do +defmodule Wallaby.Driver.JSErrorsTest do use Wallaby.SessionCase, async: true import ExUnit.CaptureIO