Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I test a GraphQL server using Mongoose with Jest

I want to test queries against my graphql implementation that is connected to a mongoose database using jest snapshot feature

I would like to follow this approach: https://github.com/nodkz/graphql-compose-examples/blob/master/examples/user/tests/queriesFromIndex.js

To use Jest snapshot to test the result of my queries.

One drawback of this approach is that I need to pre populate my mongo database with the same dummy data to always get the same results

what are the approaches to test a graphql server? including mutations and subscriptions

like image 618
Sibelius Seraphini Avatar asked Oct 16 '25 20:10

Sibelius Seraphini


1 Answers

I've wrote a blog post of how to solve this

https://medium.com/@sibelius/testing-a-graphql-server-using-jest-4e00d0e4980e#.xpi0i3d59

like image 172
Sibelius Seraphini Avatar answered Oct 18 '25 13:10

Sibelius Seraphini



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!