feat: Add metadata to cassettes #934
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thanks a lot for maintaining this library! I thought of opening a PR with a feature I think would be useful to include (it would definitely be for me 🙂).
I have a use case were I need to store additional information per test. I have a couple of scenarios in mind:
playwright
where I redirect to a browser and then come back to the test, where I need values from the resulting redirect).I thought that keeping those values in the cassette made sense, we'd call it metadata, information that is not strictly related to a particular request-response interaction, but helps run the test.
To support this I have made a couple of almost-breaking changes: the deserializer might return 3 values rather than 2 (thought of returning a dict instead to make a more similar interface to serialize, but felt "more breaking"), and
CannotOverwriteExistingCassetteException
now may not be related to a request. They are still backwards compatible, but they somewhat change the current assumptions. Not sure if you'd prefer a version bump in the cassette format and/or a deprecation warning to encourage migrating to this new version that includes metadata.Let me know your thoughts, happy to discuss the solution and improvements! 🙇