Fork me on GitHub
#clojurescript
<
2020-06-15
>
Risetto13:06:18

I'm trying split my defmethods into different files, while having the defmulti in a parent file. When google for it the recommendation is using in-ns and the loadfunction. But it doesnt seem to work in cljs

Risetto13:06:35

what is the recommended way of doing it in cljs?

dpsutton13:06:12

you should just use the (ns foo (:require [bar])) style.

pez13:06:35

Can I share a test between clj and cljs? I have an e-mail spec that relies on a regex, and would like to know that it works both in jvm and js. The way I am trying it now is to have the test in a cljc file, where the clojure test runner just finds it, but I fail to make it visible to my cljs test framework (which is using cljs.test).

dpsutton13:06:39

how does your cljs test runner find other tests defined in cljs files?

pez13:06:08

Iv’e tried to require the cljc test file (let’s say :as ct) and then (deftest email ct/email).

pez13:06:20

@dpsutton Let me check….

dpsutton13:06:37

why not just add the cljc file to the test runner the same way you add cljs files to the runner?

dpsutton13:06:42

why the intermediate?

pez13:06:51

yeah, that might be the problem. The runner uses a regex that matches all test namespaces… However, it is from one of them that I try to sneak in the cljc residing test…

pez13:06:10

I should do that w/o the intermediate, probably. Thing is I am not super familiar with the code base and it didn’t have anything testing the clojure side of the cljc defined specs before I wrote this one. So I moved this e-mail test to cljc and thought I could have it tested by just referencing it like I did.

pez13:06:57

It works fine just giving the cljc defined test namespaces to the test runner. Many thanks!!! ❤️