0
0
GraphQLquery~10 mins

Integration tests with test server in GraphQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start the test server before running tests.

GraphQL
beforeAll(async () => { await server.[1](); });
Drag options to blanks, or click blank then click option'
Astart
Bstop
Crestart
Dinit
Attempts:
3 left
💡 Hint
Common Mistakes
Using stop instead of start will shut down the server before tests.
2fill in blank
medium

Complete the code to send a GraphQL query to the test server.

GraphQL
const response = await server.executeOperation({ query: [1] });
Drag options to blanks, or click blank then click option'
Amutation
BGET_USERS_QUERY
Csubscription
DDELETE_USER_MUTATION
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a mutation or subscription instead of a query.
3fill in blank
hard

Fix the error in the test assertion to check the response status code.

GraphQL
expect(response.[1]).toBe(200);
Drag options to blanks, or click blank then click option'
AresponseCode
Bcode
CstatusCode
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using statusCode or code which are not standard in this context.
4fill in blank
hard

Fill both blanks to correctly close the test server after all tests.

GraphQL
afterAll(async () => { await server.[1](); await server.[2](); });
Drag options to blanks, or click blank then click option'
Astop
Bclose
Cstart
Drestart
Attempts:
3 left
💡 Hint
Common Mistakes
Using start or restart instead of stop or close.
5fill in blank
hard

Fill all three blanks to write a test that sends a mutation and checks the response data.

GraphQL
test('adds a user', async () => {
  const response = await server.executeOperation({
    query: [1],
    variables: { name: [2] }
  });
  expect(response.data.[3]).toBeDefined();
});
Drag options to blanks, or click blank then click option'
AADD_USER_MUTATION
B'Alice'
CaddUser
DGET_USER_QUERY
Attempts:
3 left
💡 Hint
Common Mistakes
Using a query instead of mutation, missing quotes around name, or wrong response field.