Closed escherize closed 8 years ago
I think one thing we were thinking of here was that you would get your app into a good state with a :once
fixture, and then use with-temp-re-frame-state
as part of the run-test*
in the :each
fixture. I'm not sure what the effects of resetting app-db every time would be. However we haven't really pursued running clj tests as much as I'm assuming you have, and I'm guessing you've found it to be problematic?
Based on an offline conversation with Bryan, I'm going to close this without merging.
The trick to establishing an empty state for each individual test is to:
:once
fixture establish that empty app-db staterun-test-async
macro itself using make-restore-fn
to reestablish state after each test is run. Via those two steps, each test will always start with the needed empty state.
This leaves open the path where someone wants to establish a non-empty initial state. via a :once
fixture.
Here are more details on make-restore-fn
:
https://github.com/Day8/re-frame/blob/2ccd95c397927c877fd184b038e4c754221a502d/docs/Coeffects.md#testing
The ad-hoc state of app-db shouldn't interfere with tests. And certainly shouldn't be relied upon for tests to pass.
This change will make re-frame-tests more repeatable and dependable.