Fork me on GitHub
#reagent
<
2022-02-11
>
mamapitufo12:02:13

Hello, I'm just starting with Reagent/ClojureScript, but have experience with React dev and JavaScript. I'm doing some small projects to try and get a hang of it, and I was wondering, what's the recommended practice for testing code that uses a global r/atom to hold the state? I mean, how do you reset the state in between tests of functions that manipulate that state? The functions just use state, which is required to the various namespaces.

lilactown16:02:19

you can use with-redefs to override what the var is within each test, and it will reset it once done with that test

lilactown16:02:03

note that if you tests are asynchronous with-redefs doesn't play well

mamapitufo19:02:48

thank you! I'll try that now