Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using verifyActionResult and testNextRender sequentially results in confusion on external shared states #860

Closed
weverb2 opened this issue Aug 12, 2022 · 3 comments · Fixed by #984
Labels
enhancement New feature or request testing Related to test helpers.

Comments

@weverb2
Copy link

weverb2 commented Aug 12, 2022

Discovered this while pairing with @steve-the-edwards:

Situation:
Using a Mock to verify a number of calls to a dependency of a Workflow

verifyActionResult will apply the processedAction to the current state and return a RenderTestResult, but will not apply it to the next renders.

testNextRender will also apply the processedAction to the current state and return a RenderTester allowing you to continue testing a flow of events in a workflow

The issue comes in when you are doing something like verifying calls against a mock. The action is technically applied twice to the same instance of state (potentially resulting in 2 calls to a mock when you expect 1) if you do a call chain like this:

.verifyActionResult { ... }
.testNextRender()
...

A solution could be a version of verifyActionResult that also returns a RenderTester, so you could avoid the doubly applied actions.

@steve-the-edwards steve-the-edwards added enhancement New feature or request testing Related to test helpers. labels Aug 12, 2022
@steve-the-edwards
Copy link
Contributor

cc @0legg who may have thoughts on this given he championed testNextRender

@0legg
Copy link
Contributor

0legg commented Feb 1, 2023

Got under my radar completely. Yep, it's a known issue, I've faced it before, but didn't find a way to easily fix it (like in one line). I would say "just make your actions idempotent" if I won't find a proper solution to it. :)

@0legg
Copy link
Contributor

0legg commented Feb 14, 2023

Actually, the issue is not only with testNextRender, but with chaining a set of calls to verifyAction or verifyActionResult as well. One idea I have is to cache the result of the first call computing next state within RenderTestResult. @steve-the-edwards , do you have any ideas about it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request testing Related to test helpers.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants