From 2dc6ff8fe308ac0e0f2b39a02e887fa70a6f229c Mon Sep 17 00:00:00 2001 From: Alessia Bellisario Date: Wed, 17 Apr 2024 09:33:03 -0400 Subject: [PATCH] feat: set up docs --- docs/source/config.json | 1 + .../schema-driven-testing.mdx | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 docs/source/development-testing/schema-driven-testing.mdx diff --git a/docs/source/config.json b/docs/source/config.json index 98c46b99f90..5e85cecba5f 100644 --- a/docs/source/config.json +++ b/docs/source/config.json @@ -49,6 +49,7 @@ "Developer tools": "/development-testing/developer-tooling", "Using TypeScript": "/development-testing/static-typing", "Testing React components": "/development-testing/testing", + "Schema-driven testing": "/development-testing/schema-driven-testing", "Mocking schema capabilities": "/development-testing/client-schema-mocking", "Reducing bundle size": "/development-testing/reducing-bundle-size" }, diff --git a/docs/source/development-testing/schema-driven-testing.mdx b/docs/source/development-testing/schema-driven-testing.mdx new file mode 100644 index 00000000000..24f55f0c028 --- /dev/null +++ b/docs/source/development-testing/schema-driven-testing.mdx @@ -0,0 +1,38 @@ +--- +title: Testing React components +description: Using createTestSchema and associated APIs +--- + +This article describes best practices for writing integration tests using the testing utility `createdTestSchema`. It allows developers to execute queries against a mock schema with default scalar values in order to test an Apollo Client application end-to-end, including the [link chain](react/api/link/introduction). + + + +## `createTestSchema` + + + +### Installation + +First, ensure you are running Apollo Client v3.10 or greater. Then, install the following peer dependencies: + +```bash +npm i @graphql-tools/merge @graphql-tools/schema @graphql-tools/utils --save-dev +``` + + +Usage with Jest + createFetchMock + +- FixJSDOMEnvironment +- mocking Symbol.dispose + + +Testing set-up with MSW +- separate env mocks, see MSW docs + + +FAQ + +- Don't use a single client even if it's your production client + +- Know limitation with Vite and dual package hazard +