Asynchronous ClojureScript testing : global errors in the browser

clojurescript
#1

Hi people,

Is anyone here used to do async testing with CLJS ?

I want to contribute some tests for citrus, a state manager for CLJ/CLJS. I set up the ClojureScript part with doo a wrapper around Karma to run CLJS tests in different JS environments.

Now, some API of citrus are asynchronous (dispatch! and broadcast!), and I’m writing some tests to make sure the calls fail under some conditions. However, as their async I can’t just rely on cljs.test’s (is (throw? ...)) API since it expects an error returned synchronously. As citrus uses by default requestAnimationFrame (rAF) I used the cljs.test’s async API and coupled it with rAF.

So I need to catch global errors, either by setting manually window.onerror or with window.addEventListener("error", function(){}) (with CLJS interop of course).

Here I stumbled into some weird behavior, where some previously passing tests wouldn’t pass anymore, and some becoming false positives, as well as the technique working only in some tests but not others.

My question is :

  • Has someone some experience on the matter (async testing, global errors, Karma) and could help me ?

BTW, the first link points to a work-in-progress PR for citrus, all the code is there to look at (and contribute too! :wink:).

Thanks in advance !

1 Like
closed #2