Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Getting Started with React

You're reading from   Getting Started with React A light but powerful way to build dynamic real-time applications using ReactJS

Arrow left icon
Product type Paperback
Published in Apr 2016
Publisher
ISBN-13 9781783550579
Length 212 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Danillo Corvalan Danillo Corvalan
Author Profile Icon Danillo Corvalan
Danillo Corvalan
 Sengupta Sengupta
Author Profile Icon Sengupta
Sengupta
 Singhal Singhal
Author Profile Icon Singhal
Singhal
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

The jestTypical example of a Testsuite with Mocha, expect, ReactTestUtils and Babel


Let's see a typical example of package.json, which is using the following:

  • Mocha as a testing framework

  • Expect as an assertion library

  • ReactTestUtils to test react-based JavaScript components

  • Babel used as a transcompiler, which changes the ES6 codes into currently compatible (ES5) JavaScript code.

The example of package.json file:

"scripts": {
    "test": "mocha './src/**/*.test.js' --compilers js:babel-core/register",
  },
  "devDependencies": {
    "babel-core": "6.1.4",
    "babel-loader": "6.1.0",
    "babel-preset-es2015": "6.1.4",
    "babel-preset-react": "6.1.4",
    "babel-preset-stage-2": "6.1.2",
    "mocha": "2.3.3",
    "react-addons-test-utils": "0.14.3",
  }
}

As in the previous examples, within the script object, we keep the the test files and all the test files follow the convention of ending with the .test.js extension. Any extension for the test files can be used. For compilation from ES6 code...

lock icon The rest of the chapter is locked
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Getting Started with React
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
Modal Close icon
Modal Close icon