tests: Expand helper for trace tests. #2554
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.
This one very important 115-line test:
apollo-server/packages/apollo-server-integration-testsuite/src/ApolloServer.ts
Lines 528 to 643 in c85c6d2
...has grown to a point where it's a bit conflated. Rather than becoming a new test with a separate concern, it's been added to as we've continued to expand observability features.
When looking at #1639, I was tempted to do the same thing, but felt it was worth breaking out the test into various helpers for reusability in new (upcoming!) tests.
There are two main changes here:
Rename the
error
field which is used amongst many of the tests to something more recognizable, particularly sinceerror
itself is a protobuf property which these tests exercise:apollo-server/packages/apollo-engine-reporting-protobuf/src/reports.proto
Line 108 in a849cf9
My poor brain was confused on more than one occasion by the presence of a
error
field within anerror
object, so I hope to spare those brain palpitations in the future.Turn the mock engine reporting server (meant to represent a server on the receiving side of
apollo-engine-reporting
) into a reusable, strongly-typed class:EngineMockServer
.As I noted in the commit message for 6e218ea, another take on this might have implemented
nock
, but that was a more substantial re-factor.