Skip to content

diffplug/selfie

This branch is up to date with main.

Folders and files

NameName
Last commit message
Last commit date
Jan 1, 2025
Apr 12, 2024
Mar 5, 2025
Jan 1, 2025
Jan 4, 2025
Sep 29, 2023
Dec 16, 2024
Dec 24, 2023
Dec 16, 2024
Mar 21, 2023
Dec 16, 2024
Jun 29, 2024

Repository files navigation

Selfie: snapshot testing and memoizing for Python, JVM, and (your PR here)

gif demo of selfie in action

Key features

  • Just add a test dependency (py, jvm), zero setup, zero config.
  • Snapshots can be inline literals or on disk.
  • Use expect_selfie for testing or cache_selfie for memoizing expensive API calls.
  • Disk snapshots are automatically garbage collected when the test class or test method is removed.
  • Snapshots are just strings. Use html, json, markdown, whatever. No magic serializers.
  • Record multiple facets of the entity under test, e.g. for a web request...
    • store the HTML as one facet
    • store HTML-rendered-to-markdown as another facet
    • store cookies in another facet
    • assert some facets on disk, others inline
    • see gif above for live demo, detailed example here

Python and JVM ports are both production-ready, other platforms on the way: js, .NET, go, ...

Documentation

Contributing

PRs welcome! Horror stories and glory stories too, share your experience! See CONTRIBUTING.md.

Acknowledgements

Heavily inspired by origin-energy's java-snapshot-testing, which in turn is heavily inspired by Facebook's jest-snapshot.