I have this function:
(ns cljslab.core.actions.building-blocks)
(defn objs [x]
{:pre [(not= 0 x)]}
#js {"data" x})
The goal is to test the precondition - by verifying it returns an error or throws an exception, whichever the case is:
(ns cljslab.core.actions.building-blocks-test
(:require [cljs.test :as t :refer-macros [deftest is testing]]
[cljslab.core.actions.building-blocks :refer (action objs)]))
(deftest name-test-2
(testing "Context of the test assertions"
(t/assert-predicate "something" (objs 0))))
But I am getting this error:
$ npx shadow-cljs compile test
shadow-cljs - config: /Users/blah/cljslab/shadow-cljs.edn
[:test] Compiling ...
========= Running Tests =======================
Testing cljslab.core.actions.building-blocks-test
ERROR in (name-test-2) (Error:NaN:NaN)
Uncaught exception, not in assertion.
expected: nil
actual: #object[Error Error: Assert failed: (not= 0 x)]
Ran 2 tests containing 2 assertions.
0 failures, 1 errors.
===============================================
[:test] Build completed. (70 files, 2 compiled, 1 warnings, 4.44s)
------ WARNING #1 - :undeclared-var --------------------------------------------
File: /Users/blah/cljslab/test/cljslab/core/actions/building_blocks_test.cljs:15:6
--------------------------------------------------------------------------------
12 |
13 | (deftest name-test-2
14 | (testing "Context of the test assertions"
15 | (t/assert-predicate "OK" (objs 0))))
------------^-------------------------------------------------------------------
Use of undeclared Var cljs.test/assert-predicate
--------------------------------------------------------------------------------
16 |
--------------------------------------------------------------------------------
What is missing?
(cljs.test/assert-predicate
is in the documentation of cljs.test
)