From cc4540aa3d428d149b9c77a7993bf417efc1e9a9 Mon Sep 17 00:00:00 2001 From: grandfather Date: Thu, 30 Jan 2025 18:40:27 +0100 Subject: [PATCH] Update --- packages/wallet/src/test/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wallet/src/test/README.md b/packages/wallet/src/test/README.md index e06a212447a..b91e3c250ae 100644 --- a/packages/wallet/src/test/README.md +++ b/packages/wallet/src/test/README.md @@ -129,7 +129,7 @@ To mock query resolvers in tests we can use the helper function `queryResolvers` The usage of the `queryResolvers` function is not mandatory, because we can mock resolvers without this function, but it has a few benefits: -1. In cases where queries select only a subset of document fields (e.g. `address` and `id` from the `Token` type without other properties, such as `chain`, etc.), it will automatically filter out unnecessary fields from the query response and we will get the object of shape exactly the same as specified in the query document. Without the usage of the `queryResolvers` function, responses will contain all fields of the fixture we returned from our custom resolvers, which lead to unpredictible results in some tests. +1. In cases where queries select only a subset of document fields (e.g. `address` and `id` from the `Token` type without other properties, such as `chain`, etc.), it will automatically filter out unnecessary fields from the query response and we will get the object of shape exactly the same as specified in the query document. Without the usage of the `queryResolvers` function, responses will contain all fields of the fixture we returned from our custom resolvers, which lead to unpredictable results in some tests. 2. It makes it possible to access values returned from resolvers. This is especially useful, when queries select specific fields and we want to expect test result based on what was returned from the resolver (not based on the fixture with all fields, some of which weren't present in the query response), 3. The writing of custom resolvers in tests is cleaner with `queryResolvers` and requires less code (no need to create `Query` object with resolvers, we can pass just resolvers without the `Query` object)