Fork me on GitHub
#kaocha
<
2022-01-14
>
rgm01:01:57

hi all ... is there a straightforward way to mock out re-frame's globals so that I can test some non-DOM-related code in a namespace that requires re-frame? My node-based kaocha-cljs suite breaks the instant I add a test that requires a re-frame containing namespace, based on not being able to find xmlhttprequest and window. Looks like just adding the xmlhttprequest and window npms isn't helping. I'm thinking including a simple JS file that has window = {} (no var or let) would do it here.

Noah Bogart01:01:23

Probably worth asking in #re-frame

🙏 1
rgm05:01:19

Ok so I think I'm back to this being a kaocha q ... in #re-frame the advice is to set up a preload for stubbing in globals (see https://gist.github.com/rgm/0af06f2c35aced5079b66a79081993d2). I'm hoping I'm close, but I can't seem to get "STUBBING" to print (even with --no-capture-output), plus I'm still erroring on a missing window global in a node test run. So I'm not entirely convinced the stub is running. The error I'm getting is :message "Execution error (ReferenceError) at (<cljs repl>:1).\nwindow is not defined\n". I wouldn't expect entirely smooth sailing when window is defined as an empty JS object, but I would expect to get the next interesting error instead of this one.