Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add Snapshot Testing to Fossil Test #56

Open
dreamer-coding opened this issue Jan 4, 2025 · 0 comments
Open

Feature Request: Add Snapshot Testing to Fossil Test #56

dreamer-coding opened this issue Jan 4, 2025 · 0 comments

Comments

@dreamer-coding
Copy link
Collaborator

Is your feature request related to a problem? Please describe.

Developers often need to validate outputs such as strings, JSON, or structured data against a previously approved version to ensure that changes in the code don’t unintentionally alter expected outputs. Without snapshot testing, manually verifying such outputs is time-consuming and error-prone.

Describe the solution you’d like

Integrate snapshot testing functionality into Fossil Test to automatically capture, store, and compare test outputs.

Features:
1. Snapshot Storage
• Store snapshots as files in a dedicated directory (e.g., snapshots/).
• Use test names to name snapshot files (e.g., test_function_output.snap).
• Allow storage in a custom directory via configuration.
2. Snapshot Matching
• Automatically compare current outputs with stored snapshots during test runs.
• Mark tests as failed if snapshots don’t match.
• Show a detailed diff highlighting mismatched lines.
3. Snapshot Management Commands
• --snapshot-update: Approve and overwrite snapshots with the new output.
• --snapshot-clean: Remove unused or outdated snapshots.
• CLI prompt to approve updates interactively when differences are detected (optional).
4. Data Format
• Support structured (e.g., JSON, XML) and unstructured data (e.g., strings, text files).
• Allow custom serializers and deserializers for non-text formats.
5. Integration
• Seamlessly integrate into existing Fossil Test workflows.
• Ensure compatibility with Fossil Mock for testing outputs from mocked components.
6. Reporting
• Show snapshot test results in the final test summary.
• Include snapshots in unified reporting for Fossil Test and Fossil Mock.

Describe alternatives you’ve considered
1. Manual Validation:
Developers manually check outputs by saving files and diffing them with tools like diff or git. This is tedious and not automated.
2. Custom Assertions:
Using custom assertions to check outputs against stored files. This provides partial automation but lacks integration with test frameworks.

Additional Context
• Use Cases:
• Validating API responses against known outputs.
• Checking console logs or error messages for consistency.
• Testing UI rendering outputs (e.g., HTML or JSON structures).
• Implementation Notes:
• Consider storing snapshot metadata (e.g., test environment details) alongside the snapshot.
• Offer options to ignore whitespace or specific fields when comparing snapshots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant