The TestingJavaScript community has a new home. This thread is preserved for historical purposes. The content of this conversation may be innaccurrate or out of date. Go to new community home →

We have a GraphQL backend written in Ruby which is fully tested. However, I am thinking about E2E more like a full user experience and I feel that real backend should be part of that. If I would use mocks, it's easy to make assumption that something will work in reality.

So I've attempted the approach without mocks in the past and spent like two weeks on it without any useful result. The main problem obviously is that I would somehow need to establish correct initial state before each test. This is a bit harder through GraphQL since we don't have real CRUD, but more like specific queries/mutations used in the app. Somehow it doesn't feel right to add there mutations just for tests.

I haven't attempted approach with mocks yet. It's probably a bit harder because Cypress does not support mocking GraphQL requests. I would have to setup something myself and even with that I feel that preparing mocks for each test would take more time than writing test itself.

I would like to know some opinions on this, as it's something I am personally struggling with.