Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Redux

You're reading from   Learning Redux Write maintainable, consistent, and easy-to-test web applications

Arrow left icon
Product type Paperback
Published in Aug 2017
Publisher Packt
ISBN-13 9781786462398
Length 374 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Daniel Bugl Daniel Bugl
Author Profile Icon Daniel Bugl
Daniel Bugl
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Why Redux? FREE CHAPTER 2. Implementing the Elements of Redux 3. Combining Redux with React 4. Combining Redux with Angular 5. Debugging a Redux Application 6. Interfacing with APIs 7. User Authentication 8. Testing 9. Routing 10. Rendering on the Server 11. Solving Generic Problems with Higher-Order Functions 12. Extending the Redux Store via Middleware

Setting up Jest

First, we need to set up a testing engine to be able to run tests. In this book, we will use Jest (https://facebook.github.io/jest/). Jest, like React, is developed by the Facebook open source team. Perform the following steps to set up Jest:

  1. The first step is to install Jest via npm:
npm install --save-dev jest
  1. Since we want to use the new JavaScript syntax, we also need to install babel-jest and regenerator-runtime (which is required for babel-jest):
npm install --save-dev babel-jest regenerator-runtime
If you use npm 3 or 4, or Yarn, you do not need to explicitly install regenerator-runtime.
  1. Next, we create a __tests__ directory in the project root. This is where we will put our test files.
  2. Then, we create a __tests__/example.test.js file, with the following code:
test('example test', () =>
expect(1 + 1).toBe(2)
)
  1. Finally, we define a test...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image