September 2017
Intermediate to advanced
120 pages
2h 47m
English
Let’s add some tests to the word counter project. We’ll start by installing a test framework that runs our tests and reports the test results. We’ll use Jest[15] because it offers an excellent out-of-the-box experience, but you can apply the techniques you’ll learn to other test frameworks.
Navigate to the word counter project directory and install Jest as a development dependency:
| | $ npm i --save-dev jest |
Since your code uses JSX, you also need to transpile the code when you run the tests. A Jest plugin called babel-jest ensures Jest transpiles the test code with the Babel configuration it finds in the package root. Install the babel-jest plugin as a development dependency:
| | $ npm i --save-dev ... |
Read now
Unlock full access