Book Image

React.js Essentials

By : Artemij Fedosejev
Book Image

React.js Essentials

By: Artemij Fedosejev

Overview of this book

Table of Contents (18 chapters)
React.js Essentials
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Installing and running Jest


First, let's install the Jest command-line interface (Jest CLI):

npm install –-save-dev jest-cli

This command installs the Jest CLI, and adds it as a development dependency to our ~/snapterest/package.json file. Next, let's edit the package.json file. We'll replace the existing "script" object:

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1"
},

Replace the preceding object with the following one:

"scripts": {
  "test": "jest"
},

Now we're ready to run our test suit. Navigate to the ~/snapterest/ directory, and run the following command:

npm test

You should see the following message in your Terminal:

Using Jest CLI v0.4.18
 PASS  source/utils/__tests__/TweetUtils-test.js (0.065s)
1 test passed (1 total)
Run time: 0.295s

As you can see, I am using Version 0.4.18 of the Jest CLI. When you run your test, the Jest version is likely to be higher than this.

The key line in this message is as follows:

PASS  source/utils/__tests__/TweetUtils-test...