Closed practicalli-johnny closed 1 year ago
document is not defined
This usually means you're using libraries that expect a DOM (i.e. they expect to find js/document
), but you are using them in an environment where there is no DOM, typically Node. That's also what is happening here. You are including goog.dom
and reagent.dom
, so it's clear you expect to find a DOM, and kaocha-cljs's default behavior is to use the Node REPL to execute tests.
If I instead instruct it to use a browser REPL then all is well.
#kaocha/v1
{:source-paths ["src"]
:tests [{:id :unit-cljs
:type :kaocha.type/cljs
:cljs/repl-env cljs.repl.browser/repl-env}]}
~/github/clojurescript-figwheel-main-hello-world on main
➜ bin/kaocha
[(..)]
2 tests, 2 assertions, 0 failures.
If there's anything actionable here it's probably to add a FAQ about this particular error to the README. A similar thing can happen with js/fetch
Description :octocat:
Running kaocha-cljs on a project generated from the fighwheel-main template fails, with
cljs repl - document is not defined
error.The figwheel-main test runner succuessfully runs runs the 2 unit tests that are generated from the figwheel-main template, using the command
clojure -M:fig:test
. Both tests pass.Reproduction guide :beetle:
Generate a new project using the fighwheel-main template with the
--reagent
option (:project/new
is a user-level alias for clj-new)Add koacha-cljs following the instructions in the README (commit on example repo)
add an alias called :kaocha-cljs to deps.edn
create a
tests.edn
filecreate a
bin/kaocha
filerun tests using
bin/kaocha unit-cljs
Observed behaviour: :eyes: :broken_heart: The command line shows the test run has an error and prints out a long stack trace
A summary of the error:
Full error report
```clojure {:via [{:type clojure.lang.ExceptionInfo, :message "Execution error (ReferenceError) at (Complete terminal output
``` ❯ bin/kaocha unit-cljs [(E] Randomized with --seed 1633805738 ERROR in unit-cljs (main.java:37) Unexpected error executing kaocha-cljs test suite. Exception: clojure.lang.ExceptionInfo: ClojureScript Exception {:via [{:type clojure.lang.ExceptionInfo, :message "Execution error (ReferenceError) at (Expected behaviour: :heart: :smile: kaocha-cljs should discover and run two unit tests and both tests should pass
System Info :computer: