Open ziimakc opened 1 year ago
Currently it doesn't look like it is possible to test the response headers. The response heads could be exposed to this function since under the hood it uses fastify.inject
which does give you the response headers.
My use case for testing the response headers is the following. My app has a sign-in GraphQL mutation, that uses @fastify/session
to create a signed session cookie. The GraphQL mutation does not respond with the value of the cookie. This is fine for testing authentication. The logout GraphQL mutation calls session.destroy()
and when I send the request to logout, I would need to send the sessionId
cookie with the signed cookie value that I do not have. To fix this, we could modify the mercurius-test-client
to also return the response headers (where I could get the set-cookie
header value and use the cookie for the subsequent logout mutation) in addition to the response body. This, however, would be a breaking change.
I do like the simplicity of this module. @PabloSzx, in this situation, do you think we should modify mercurius-test-client
to return the response headers in addition to the response body for this test case or should I just use fastify.inject
? Either solution seems fine to me.
Is there a way to test response headers?