p2p-db / test / ird / p2p / db / browser / runner.cljs
127 words
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(ns ird.p2p.db.browser.runner
  "Entry point of the browser test build (shadow-cljs :browser-test): runs
  the browser test namespaces with cljs.test and leaves the summary on
  `window.__ird_test` for the Node harness to read. The page loads the
  vendor chunk before this build (it installs Buffer, which the byte
  helpers use as their namespaces load); `init` checks the import helper
  resolves before running anything."
  (:require [cljs.test :as t]
            [ird.p2p.db.browser.harness :as h]
            [ird.p2p.db.browser.replication-test]))

(def ^:private print-summary (get-method t/report [::t/default :summary]))

(defmethod t/report [::t/default :summary] [m]
  (print-summary m)
  (set! (.-__ird_test js/window) (clj->js (select-keys m [:test :pass :fail :error]))))

(defn init []
  (h/configure!)
  (-> (js/ird_dyn_import "helia")
      (.then (fn [_] (t/run-tests 'ird.p2p.db.browser.replication-test)))
      (.catch (fn [e]
                (js/console.error "the vendor chunk failed to load:" e)
                (set! (.-__ird_test js/window) #js {:test 0 :pass 0 :fail 0 :error 1})))))

static mirror of HEAD · about · clone: git clone https://ird.cod-sursa.ro/p2p-db.git