Last active
July 14, 2023 10:42
-
-
Save henryw374/6ba4359f540412baae4510d790fcf273 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns com.widdindustries.kaocha-cljs2-ns-pattern-hook | |
"the only way I can find to filter kaocha-cljs2 tests by pattern. see comment block for usage" | |
(:require [kaocha.core-ext :as core-ext] | |
[kaocha.load :as load])) | |
(defn ns-filter [plan] | |
;(def plan plan) | |
;(println "About to start loading!") | |
(update plan :kaocha.test-plan/tests | |
(fn [tests] | |
(->> tests | |
(mapv (fn [testable] | |
(if (not= :kaocha.type/cljs2 (:kaocha.testable/type testable)) | |
testable | |
(if-let [ns-patterns (some->> testable | |
:kaocha/ns-patterns | |
(mapv core-ext/regex))] | |
;(def testable testable) | |
(update testable :kaocha.test-plan/tests | |
(fn [tests] | |
(->> tests | |
(map (fn client-type [client-testable] | |
(update client-testable | |
:kaocha.test-plan/tests | |
(fn ns-tests [ns-testables] | |
(->> ns-testables | |
(filter (fn [ns-testable] | |
(load/ns-match? ns-patterns (:kaocha.testable/name ns-testable)))))))))))) | |
testable)))))) | |
)) | |
(comment | |
; example tests.edn content | |
; #kaocha/v1 | |
; {:plugins [:hooks] | |
; :kaocha.hooks/post-load [com.widdindustries.kaocha-cljs2-ns-pattern-hook/ns-filter] | |
; :tests [{:id :browser-tests | |
; :type :kaocha.type/cljs2 | |
; :kaocha.cljs2/timeout 30000 | |
; :ns-patterns ["demo-app"]}]} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment