So far, we've managed to test our server and all GraphQL API functions. Currently, however, we're still missing the tests for our front end code. While we render the React code when requesting any server route, such as the /app path, we only have access to the final result and not to each component. We should change this to execute the functions of certain components that aren't testable through the back end. First, install some dependencies before using npm:
npm install --save-dev enzyme enzyme-adapter-react-16 ignore-styles jsdom isomorphic-fetch
The various packages are as follows:
- The enzyme and enzyme-adapter-react-16 packages provide React with specific features to render and interact with the React tree. This can either be through a real DOM or shallow rendering. We are going to use a real DOM in this chapter because it allows us...