Cannot display full error trace
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 123
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
Context
When I run my shiny app in R Studio Server (linux), in my console I see all the custom logging statements from my server.R script, and, importantly, the error that caused the app to crash (i.e. "Column ExitAdjust doesn't exist"):
Brief explanation of how the app works
The user uploads a zip file, which the app then processes in sequential steps, beginning with the "Running get export" step, then "Running dates", ..., then "Running initial data prep". (There are actually a few more steps that are supposed to run after that, but the app is crashing during that last step because I'm trying to select() a column (ExitAdjust) from a dataframe that doesn't contain that column. That's all expected behavior - the app should crash!
My Issue
How do I get shinytest2 to reflect that same error? When I run my test, I don't see the error in the console. Instead, I get something like this:
Relevant code behind the test:
test_that(paste0("{shinytest2} recording: ",test_script_name), {
print(paste0("Running ",test_script_name))
app <- AppDriver$new(
variant = platform_variant(os_name = FALSE),
name = test_script_name,
seed = 12345,
load_timeout = 1e+05)
app$set_inputs(Go_to_upload = "click")
app$upload_file(imported = paste0("../",test_dataset))
app$expect_values() # FAILS HERE BECAUSE APP HASN'T FINISHED PROCESSING BECAUSE OF THE AFOREMENTIONED ERROR
})
The test is opening the app, going to the page where the file gets uploaded, uploading the file, then trying to take a snapshot. Unsurprisingly, the test fails trying to take the snapshot because the app never finishes processing the uploaded file due to the aforementioned error. Unfortunately, though, the log isn't very helpful. I.e., it's not clear WHY the app is failing.
What should happen
Ideally, it would print all the same stuff as when I run the app regularly, but especially the error message.
What I've tried
I've tried the following things, but saw no changes in the log:
- Add to my app initialization:
options = list(shiny.trace = TRUE, shiny.fullstacktrace = TRUE) - Add to my app initialization:
options = list(shiny.trace = TRUE) - Add below my app initialization:
app$get_logs()
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the AppDriver$new setup and the failed app$expect_values() call in the provided test, then compare the output with app$get_logs() after the upload. Reproduce the failing upload and trace how the underlying Shiny error is surfaced in the test log. Done means the failure output exposes the original error message and useful trace information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100