The Jest command-line tools are all you need to run your unit tests. There are a number of ways that the tool can be used. First, you'll learn how to invoke the test runner from a create-react-app
environment and how to use the interactive watch mode options. Then, you'll learn how to run Jest in a standalone environment without the help of create-react-app
.
When you create your React application using create-react-app
, you're ready to run tests right away. In fact, as part of the boilerplate code that's created for you, a unit test for the App
component is created. This test is added so that Jest will find a test that it can run. It doesn't actually test anything meaningful in your application, so you'll probably delete it once more tests are added.
Additionally, create-react-app
adds the appropriate script to your package.json
file to run your tests. You can just run the following command in your Terminal:
npm test
This will actually invoke the...