We use Fake Adapter style to test use cases because use cases contain most of the logic.
For IO layers, we prefer to Mock Adapter style because we care more about the correctness of API integrations here, assuming use case logic is always right.
The test flow is:
Start GraphQL Http Server
Build GraphQL query
Send the query to the server
Assert response.
Do not assert on any server internal behaviors.
Add mock style unit tests to GraphQL layer.
As a thumb of rule:
Fake Adapter
style to test use cases because use cases contain most of the logic.Mock Adapter
style because we care more about the correctness of API integrations here, assuming use case logic is always right.The test flow is:
Potentially helpful packages: