#nest js graphql E2E test help

14 messages · Page 1 of 1 (latest)

untold talon
#

I am trying to write an E2E test for a graphql resolver . The issue is inside the service layer , we use request from the graphql context which has user info . How can I mock the request info so that I can run the E2E test . Appreciate any help

untold talon
#

Any help please ?

proud locust
#

Send an actual request? That would be how an e2e test should work, right?

untold talon
#

Yes but I get an error saying request is undefined

proud locust
#

What's the error? What's the request look like?

untold talon
#

This is the E2E test suite

#

And this calls the create mutation resolver and in the service layer of create the service method takes request as one parameter which is from ExecutionContext

indigo lavaBOT
#

:warning: Please do not screenshot code as it causes a number of issues:

  • Ease of assistance: if someone wants to copy your code and correct it, they cannot. Making it easy for people to help you is in your best interests.
  • Editorializing: it's common to try to make images small, which means you're likely to crop out code relevant to your issue
  • Accessibility: wide images can be hard to read on mobile devices, and are impossible for screen readers.
  • Legibility: you cannot read screenshots of code directly, instead you have to open them in an enlarged context.
  • Bandwidth usage/clutter: some of our members use metered connections, and it is wasteful for them to download images of a text.

For a small amount of code, please use a code-block.

untold talon
#

And in the code we access request headers section and that is being undefined

#

That’s the core issue

#

The headers section has user info

proud locust
#

I can't read the photo you took. Please actually paste code in a code block

spare sandal
#

Hello @untold talon , recently i have been assigned to write a test cases of a one project , which is written in nest + graphql and they used prisma orm in it.
i have did testing before it but in express, i don't have much idea about how to write test cases for a graphql app.
so can you share me some resources from where do you learn also can you share me any of your repo for refrence, it would be a great help.
Thanks.