Skip to content

Latest commit

 

History

History
35 lines (18 loc) · 1.86 KB

README.md

File metadata and controls

35 lines (18 loc) · 1.86 KB

Example Tests

This directory contains example tests. Their purpose is to give a gentle introduction to the test tools used in this project.

To run all of the tests on all of the examples, run yarn test:examples from the root directory.

These tests are intended to run on CI, as it keeps them working in the context of changes to the surrounding project. If any of these tests start to fail, please correct the underlying issue rather than disabling the test or example_tests entirely.

This is an extremely basic "Hello, world!" sort of application, and has a correspondingly simple test.

Promises can complicate testing. This shows two simple ways of dealing with that.

Matchers are functions that verify that some value (received) matches some condition exists in some relationship with a comparison value (expected). This set of tests demonstrates a variety of matchers, how they are used, and some possible surprises in using them.

This covers simple tests for a simple component, for developers new to React or Jest.

This component is more complex; it renders a header, <select> element, and a conditional <div> displaying an alert. It maintains internal state and reacts to user events.

This shows how to perform accessibility tests within unit tests.

Mocks are only useful if they accurately mirror production responses; this example shows how to use nock, which is used to record and play back network requests and responses for use as mock fixtures.