<  Back to Schedule
GraphQL ClientSession Presentations

Schema-Driven Testing with Mock Service Worker

Tuesday, September 10 / 10:50a.m. PDT - 11:20a.m. PDT
Alessia Bellisario Profile Image
Alessia BellisarioApollo, Staff Software Engineer

At last year’s GraphQL Conf, Stephanie Saunders sang the praises of schema mocking in her excellent talk “Sophisticated Schema Mocking”. As Stephanie outlined, tests written using mock schemas have several benefits over ones written with static response mocks (seriously, go back and watch the talk if you haven’t!) Mock schemas are the perfect pair for Mock Service Worker which describes itself as “an API mocking library that allows you to write client-agnostic mocks and reuse them across any frameworks, tools, and environments.” In this talk, I’ll demonstrate how to use mock schemas with MSW using testing tools created by the Apollo Client team. These utilities can be used with any GraphQL client for the web whether it’s Apollo Client, Relay, urql, isograph or even just plain fetch requests to a GraphQL endpoint, and support incremental delivery (@defer/@stream), subscriptions and more. With MSW + your front-end stack of choice + test runner or framework of choice (Jest, Puppeteer, Cypress, Storybook, the list goes on) this talk will teach you how to level up the tests you and your team are writing.