How does a test response body get generated?
In /refine/packages/hasura/test/getList/index.mock.ts,
it looks like the nock responses are a long string
"1f8b08000000000004037d93516bdc300cc7bf8ac973058ee3c4f6bdf5c6b60eb651dabe8d326459be0b4d9312e70adbd1ef3eb5db989f663058c6fcf4f75fd2b949b861b33b374f4bd94ab3fb766ec6d4ec9a8864386b041f42063b040bde72861868c86c1399e89a8b661bb789e53996945f77c1949b970bf597d2060a3159483907b04c19903203321ab214986c5b512e0f3c6f6acfeb43398e2bab9b53d946aa789452b2c40986be4d60751700236b30182443244fde54bc0f0b9d8a3aaccbe9495d9d1e7156b713f3430df4865c4b3de8aca300ad911f62072906e7321b8fbeab80ef219eca3873290a275c1f456bcacb9adee45658a6e4104d0b6dc856dca300913a06635ca2a4bd7639fd075b915c9f62f6dac39048838d2e424c2d426e73e75b66cd962ad27e99c6e711e7457d794ecba4f666af6e711457af78e219d5f5729a53cd77beeb07f72a2d1bb0b9b7c24771817c6f2c7618a876f42b6ee332e3a43eae388f1babc7651b9fe5723e5450efd13a292e98304899248240bd0317add7127a3dd4cd73854f526675b71c16b5cc93f82bb92b9cf3c17b173be0dcf560c9690859eadf3b313979491243e5c11dc689d5a73949f7aca3687d77647a1085ea9248bebf05df56f4905c707a304011a5d3b175e05b43d0b7d60d98b3b5b676e09ad7f2e6c0e745fae90f51951ff376e432fe7c4d73c38571a5e36075f3727ff17bb4bee3e1b0f20137199773f32f503b199637598d1c4dff22eb17578a0b6196030000"
How does this get transformed into the response that is used for assertions in the spec file?
7 Replies
Hi @matt.ho. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Hmm, I don't know enough to give you a confident answer yet. However, you can refer to the refine documentation for more information: https://refine.dev/docs
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------Overview | refine
What is refine?
<@692495582262067261> kapa.ai is still learning and improving, please let us how it did by reacting below
multiple-amethyst•2y ago
Hey @matt.ho,
First comment the
import "./index.mock";
import in getList/index.spec.ts
. Then, import nock
from nock
. Finally you can use the nock to record API responses like below:
When you run the test, it will write the mock response in your terminal, don't forget to save it in the index.mock
file.solid-orange•2y ago
@salihozdemir How does the data object get defined?
multiple-amethyst•2y ago
Do you mean something like this?
Btw, you can check out it: https://refine.dev/blog/mocking-api-calls-in-react/ for more details about nock.
solid-orange•2y ago
Yes! Oh exactly what I'm looking for. Than kyou