How to only validate the sequence of actions while ignoring state change

In our code base we have actions A, B and C that have been thoroughly tested.
With a new requirement, a new action D has been introduced which returns a merged Effect on actions A, B, and C.

When I go to test action D, I want to only test the sequence of sub actions that are generated and ignore assertions on state because as I mentioned before A, B, C have been thoroughly tested individually. Being forced to assert state when I am writing tests for D is leading to duplicate and redundant code.

What would be nice is is if we had a Step called expect() which would work something like this:

store.assert(.send(D), .expect(A), .expect(B), .expect(C))

This goes against the very grain of TCA, but I believe much needed for a situation like this.

If there is another way to approach this, I'd be happy to learn about it :slight_smile:

Do you have to use the test store? In this specific use case I think, as long as you're testing A/B/C elsewhere, maybe sending an action (and environment and state) through the reducer and then asserting on the results of the effects directly might be a simpler way to go.

Test stores have a scope method that lets you test view state, so I think you could scope it to a type that ignores state and state changes:

struct Stateless: Equatable {} // because Void is not yet Equatable

store.scope(state: { _ in Stateless() }).assert(...)
Terms of Service

Privacy Policy

Cookie Policy