fix(shinytest2): Fix broken shinytest2 testing; Legacy muffle expectation and muffled snapshot_fail support#2294
Merged
Merged
Conversation
While we don't support `continue_test` directly, it has the same intent as `muffle_expectation` as it was the previous name. So support it in the handler.
… and return `TRUE`
1 task
schloerke
commented
Nov 21, 2025
Comment on lines
+6
to
+24
| 4: expectation("failure", message, srcref = srcref, trace = trace) | ||
| 5: exp_signal(exp) | ||
| 6: withRestarts(if (expectation_broken(exp)) { | ||
| stop(exp) | ||
| } else { | ||
| signalC | ||
| 7: withRestartList(expr, restarts) | ||
|
|
||
| 1: f() | ||
| 2: expect_true(FALSE) | ||
| 3: expect_waldo_constant_(act, exp, info = info, ignore_attr = TRUE) | ||
| 4: fail(msg, info = info, trace_env = trace_env) | ||
| 5: expectation("failure", message, srcref = srcref, trace = trace) | ||
| 6: exp_signal(exp) | ||
| 7: withRestarts(if (expectation_broken(exp)) { | ||
| stop(exp) | ||
| } else { | ||
| signalC | ||
| 8: withRestartList(expr, restarts) |
Contributor
Author
There was a problem hiding this comment.
I don't know why this change is necessary for the PR.
Did I do something odd to require the change?
Member
There was a problem hiding this comment.
I think DebugReporter automatically trims off some number of frames to avoid showing too much testthat machinery. You wouldn't think that your change would affect this but I'm pretty sure withRestarts(code, a, b) is implemented as withRestarts(withRestarts(code, a), b) internally. Let me see if I can tweak some magic numbers somewhere.
Member
There was a problem hiding this comment.
Only took like 4 tries but I figured it out.
This was referenced Nov 21, 2025
Contributor
Author
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2293
Fixes #2288
shinytest2::AppDriver$expect_values()takes a snapshot of the values received from Shiny. No problems.However, it also takes a screenshot snapshot of the app at the time of the values. This extra snapshot is added for git tracking purposes, not unit testing. This snapshot should never fail.
When
return(snapshot_fail())expectation was muffled, the return was equivalent toreturn(invisible())which is a NULL value. The fix is to not immediately return and to carry on as iffail_on_new == FALSE