Skip to content

Commit

Permalink
feat: set up docs
Browse files Browse the repository at this point in the history
  • Loading branch information
alessbell committed Apr 17, 2024
1 parent a4c89f0 commit 2dc6ff8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/source/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
38 changes: 38 additions & 0 deletions docs/source/development-testing/schema-driven-testing.mdx
Original file line number Diff line number Diff line change
@@ -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).

<MinVersion version="3.10">

## `createTestSchema`

</MinVersion>

### 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

0 comments on commit 2dc6ff8

Please sign in to comment.