Skip to content

feat: Test-mode snapshot preprocessing (snapshot_preprocess_input/output) #2282

Description

@schloerke

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions