Clojurians
# test-check

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

ag 20:32:28

hey guys… does anyone know why
(defspec foo-test 100 (prop/for-all [m (s/gen ::bool-kv)] ,,,

is failing when run in clojurescript with lein-doo in phantomjs? throws this: ERROR in (foo-test) (clojure$test$check$generators$call_gen@file:222:20) Uncaught exception, not in assertion. expected: nil actual: #object[TypeError TypeError: null is not an object (evaluating 'generator_fn.call')]

lucasbradstreet 20:54:11

@ag my work mate had a similar problem to that and it was due to not requiring something

lucasbradstreet 20:54:28

I was surprised that cljsbuild didn’t warn about it

lucasbradstreet 20:54:40

Your mileage may vary, but it’s worth checking

ag 20:55:18

actually same code works when compiled javascript directly passed to karma (without using lein-doo)

ag 20:55:25

I want to use lein-doo though

lucasbradstreet 21:05:43

Are they using different compiler modes? i.e. advanced vs none?

ag 21:07:46

it completely breaks with :simple. java.lang.AssertionError: Assert failed: No file for namespace my-app.test-runner exists

ag 21:09:09

with :whitespace it fails with a different error:
Error: Cannot find module 'function (f) {if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.React = f()}}’

lucasbradstreet 21:10:25

Seems like a require error, but I don’t know too much more

lucasbradstreet 21:13:25

I think it’s quite likely not to be a doo error

lucasbradstreet 21:14:33

Try requiring clojure.test.check.generators

lucasbradstreet 21:15:01

Possibly shouldn’t need to, but I think it might be a bug in the cljs compiler if it’s not warning about it

ag 21:16:40

still the same :disappointed:

lucasbradstreet 21:16:59

I asked my co-worker and his was clojure.test.check.properties

ag 21:17:24

I do have that require

ag 21:17:27

[clojure.test.check.properties :as prop]

lucasbradstreet 21:18:25

OK, I’ve got nothing then :slightly_smiling_face:

ag 21:19:35

so I’m wondering if it has something to do with how I require clojure.spec.generators?

ag 21:20:44

so here’s the thing to require clojure spec, in clojurescript you can either do require '[cljs.spec,,, or require '[clojure.spec,,,

ag 21:20:58

but when it comes to generators it’s not that smart

ag 21:21:17

you can’t do require '[clojure.spec.generators]

ag 21:21:45

I found a way to include them like this [cljs.spec.impl.gen :as gen]

ag 21:21:56

but maybe that’s not completely right?

ag 21:22:28

but then why the same code compiled and run outside of doo works fine?