How to use spec generators in ClojureScript?

It’s said to be short in Guides,

(gen/generate (s/gen int?))

But as I run it, I’m using ClojureScript, and the code is mostly copied from Web via Google,

(ns example.core
 (:require [cljs.spec.alpha :as s]
           [expound.alpha :refer [expound]]))

(s/def ::age number?)

(s/def ::name string?)

(s/def ::example (s/keys :req-un [::age] :opt-un [::name]))

(println (s/exercise string?))

I’m running it with Lumo, so I tried to add dependencies,

lumo -K -D expound:0.7.2 -D org.clojure/test.check:0.10.0-alpha4

And I got error,

No such namespace: cljs.test.check.generators, could not locate cljs/test/check/generators.cljs, cljs/test/check/generators.cljc, or JavaScript source providing "cljs.test.check.generators"

Most of the examples was in Clojure, so I think it’s reasonably different when it comes to ClojureScript, in shadow-cljs and Lumo.

So how to run it correctly?

Works on my machine. Maybe you have to upgrade lumo?


Turned out Lumo is not downloading the dependency for me. I told shadow-cljs to download the package, and now it works.

1 Like