feat: add context.query()
to nock back
#2553
Merged
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.
When TDDing using Nock Back you're kind of in a Chicken-and-Egg situation. You want to be able to verify the external calls you need to make - but you don't know the exact nature of those external calls. This lets you list the interceptors created in a given fixture to make sure all the ones that you expect are there.
By itself, this functions as a negative expectation - like I can verify that certain calls do NOT happen in the fixture. When paired with
assertScopesFinished
this can be used to verify the complete set of calls in the fixture. For instance I have a fairly complex HTTP interactor that synchronizes a local data store with a remote one. I know how many calls this takes - and I know that if the scopes in the fixture complete then my interaction worked.But if I need to re-record my interaction, I need to go over to the fixture and check it manually. This lets me make assertions about what is in the fixture - so that I can re-record them and verify that they still do what I expect.
Example Code Simplified and Anonymized to the Point Of Inaccuracy: