You can simply use the npm test with any invited tester. I use mocha and tea. Jest might be a little better, as I consider it probably the most advanced test suite. You just created the tests, like any endpoints.
it('should be null when user is not logged in', async () => { const query = ` query { user(id: "") { username email } } ` const rootValue = {}; const context = {}; const result = await graphql(schema, query, rootValue, context); const { data } = result; expect(data.user).to.equal(null); });
pretty easy way to check it out. You also run the statement before pasting the appropriate user into your db. The problem with maintaining a separate test suite is that you need to access db directly. Your tests should not rely on other API calls, as this creates unnecessary dependencies. Therefore, if the test is interrupted, suddenly the root cause is more difficult to understand.
Byrd
source share