Skip to content

Testing with supertest in an Express server #2894

Closed Answered by davlet61
davlet61 asked this question in Q&A
Discussion options

You must be logged in to vote

I am not sure how you tried GET requests but GET requests don't have request bodies so you need to add query and variables as search/query parameters to the URL.

Yes, I am aware of that, not sure how it worked either 😀
But the codebase had these tests everywhere and none of them failed until I migrated to Yoga :

it('should return an account', async () => {
 	const query = `
        query getSingleAccount($id: Int!) {
          account(id: $id) {
            foo
          }
        }`;
     const params = {
        query: query,
        variables: {
          id: account.id,
        },
      }
     const res = await request(app)
        .get('/graphql')
        .set('Authorization', auth…

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
9 replies
@davlet61
Comment options

@EmrysMyrddin
Comment options

@davlet61
Comment options

@davlet61
Comment options

@ardatan
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by n1ru4l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants