Part of #2269 (deferred from PR #2270).
Shiny for R lets app authors register per-value transforms that run before a value is written to the test snapshot, via snapshotPreprocessInput(inputId, fn) and snapshotPreprocessOutput(output, fn). These are essential for scrubbing non-deterministic values (timestamps, temp paths, random ids, session tokens) so snapshots diff cleanly across runs.
py-shiny's test mode (PR #2270) does not yet have an equivalent. This issue tracks adding it.
Scope / open questions
- API shape: session methods and/or free functions (mirroring how
export_test_values landed in shiny.session)? Where do preprocessors live?
- Which blocks:
input and output (as R), and/or export?
- How preprocessors are keyed (per input/output id) and applied in
AppSession._handle_test_snapshot before _snapshot_safe_value.
- Namespacing behavior in modules (consistent with the export-name namespacing deviation from R).
References
- Server handler:
shiny/session/_session.py _handle_test_snapshot
- R behavior:
enableTestSnapshot in rstudio/shiny R/shiny.R (getSnapshotPreprocessInput / getSnapshotPreprocessOutput)
Part of #2269 (deferred from PR #2270).
Shiny for R lets app authors register per-value transforms that run before a value is written to the test snapshot, via
snapshotPreprocessInput(inputId, fn)andsnapshotPreprocessOutput(output, fn). These are essential for scrubbing non-deterministic values (timestamps, temp paths, random ids, session tokens) so snapshots diff cleanly across runs.py-shiny's test mode (PR #2270) does not yet have an equivalent. This issue tracks adding it.
Scope / open questions
export_test_valueslanded inshiny.session)? Where do preprocessors live?inputandoutput(as R), and/orexport?AppSession._handle_test_snapshotbefore_snapshot_safe_value.References
shiny/session/_session.py_handle_test_snapshotenableTestSnapshotinrstudio/shinyR/shiny.R(getSnapshotPreprocessInput/getSnapshotPreprocessOutput)