I'm writing unit tests for several Flux stores and encountered a small annoyance.
My stores are generally built like this:
storeObj = {
...
}
_secretsetterfunction = function (){}
module.exports storeObj
As you can see, since the setter function is outside of the store object - it's not directly accessible.
This presents a problem as the only way to test / manipulate the store data would be to go through the Action -> Dispatcher -> event listener (the Action can technically be cut out) which isn't something I would like to go through when unit testing a store.
The alternative is to actually put the setter methods on the store object - but this isn't something I'd really wish to do.
Any thoughts?
So The flux team just addressed this in a blog post, though they are using their own variant called Jest. Still worth a read: