day8 / re-frame-test

Cross platform (cljs and clj) utilities for testing re-frame applications
MIT License
109 stars 12 forks source link

run-test-{a}sync resets app-db to {} while testing #4

Closed escherize closed 8 years ago

escherize commented 8 years ago

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.

danielcompton commented 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?

mike-thompson-day8 commented 8 years ago

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:

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