                                                    (swap! log conj formatted-output-str)))}}})
     log))
 
-(defn- make-automation [client-config]
-  (let [client (c/make-ws-client client-config)
-        max-wait-time-ms 1000
-        conn (c/connect "localhost" port max-wait-time-ms client)]
-    (create-automation conn)))
+(defn- make-conn
+  "The main reason we need this is so it’ll use the value of the port var. See the comment on that
+  var above."
+  ([] (make-conn {}))
+  ([client-config]
+   (let [client (c/make-ws-client client-config)
+         max-wait-time-ms 1000]
+     (c/connect "localhost" port max-wait-time-ms client))))
 
 (deftest logging
   (testing "messages that are larger than the max should cause an error to be logged"

(ns clj-chrome-devtools.impl.connection-test
  (:require [clj-chrome-devtools.automation :refer [create-automation current-automation evaluate]]
            [clj-chrome-devtools.automation.fixture :refer [create-chrome-fixture]]
            [clj-chrome-devtools.impl.connection :as c]
            [clj-chrome-devtools.impl.util :as util]
            [clojure.spec.test.alpha :as stest]
            [clojure.string :refer [includes? join]]
            [clojure.test :as t :refer [deftest is testing]]
            [taoensso.timbre :as log]))

(stest/instrument)


          (is (re-seq #".+WARN.+WebSocket connection closed with status code 1009 \(Too large\) and reason: Text message size.+exceeds maximum size.+"
                      output)))))
    (testing "specified limit (2MB)"
      (let [conn (make-conn {:max-msg-size-mb (* 1024 1024 2)})
            automation (create-automation conn)
            eval-timeout-ms 1000 ; Specify a short timeout because this error case would otherwise
                                 ; cause evaluate to hang until its default timeout of 60 seconds
                                 ; elapses, which would just be too slow.
