I'm encountering a fun little problem with unit testing and the flux data stores.
Since the data stores are singletons that only get instantiated once (when the module is imported) any changes you make in your unit test persist.
This can (and is) causing me all sorts of head aches.
The solution I'm currently implementing is a reset method on each store which I run within the afterEach but I was wondering / hoping there's a simpler way to go around this?
Require your dispatcher, store and get the reference to the callback all within a beforeEach(). This blows away the old stuff and gives you fresh stuff for each test.
Example of this is in the blog post: http://facebook.github.io/react/blog/2014/09/24/testing-flux-applications.html#putting-it-all-together
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With