2

I am writing a Node.js application that acts as GraphQL server. And I want to test if GraphQL is giving me the right results.

My guess is to make a request to server in each test and then watch if it is right or not. But I'm not sure how to set it up, how to run the server and clean the database before all tests and shutting it down after all tests are finished.

I worked with rspec using Ruby on Rails before, so I want to do something like rspec does in Node.js. Is there a way to accomplish it using Jest? And if not, how can I do something simular?

1 Answer 1

3

This isn't really an Jest specific question but more how to perform integration testing in Node.

The fact you're using Jest makes very little difference other than you'll want to ensure auto mocking is turned off.

Normally when writing integration style tests I'd use something like supertest to make requests and setup the database to use sqlLite or similar running a seed.

I'd recommend looking for similar tools like graphql-tester.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah, I think you're right, this question is more about integration testing in Node.js. I've change the question title to represent it. And thanks for the answer!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.