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.
PR for our telegram conversation.
This allows us to have context on fixture files. If you have a general/dynamic connector mock for your tests you will end up with a bunch of fixtures you have no idea where they belong to. It is even worse when you use some payload hashing as below.
As you can see each different request will end up with a corresponding fixture - but you won't be able to tell from a fixture where it belongs to, if it's still needed or anything.
That's where fixture context comes in handy - you can add whatever context you want that will be persisted in your fixture files - for example the plain payload or the name of the test it was used in or anything else.
You can do so by chaining
withContext()
on your fixture instance.usage examples
You have access to the underlying
ArrayStore
viagetContext()
and can use all the methods available there to manipulate or interact with the context. For sure you can also usegetContext()
to retrieve a specific context value.The context isn't used anywhere in Saloon itself - it's only made available and persisted so that you can check it manually or do some checks in your own code with it. So everything you do with it is up to you - only restriction: it has to be JSONable.