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
Free Learning
Arrow right icon

Jest 23, Facebook’s popular framework for testing React applications is now released

Save for later
  • 3 min read
  • 05 Jun 2018

article-image

A new version of Jest, the popular framework for testing React applications is now available. Jest is developed by Facebook and can be used for testing JavaScript functions, but is specifically aimed at React. Jest is a zero configuration testing platform with features such as snapshot testing, parallelized test runs, built-in code coverage reports, and instant feedback.

Jest 23 features major updates. Here are the top ones.

Babel and Webpack join the Jest community


Webpack saw their total test suite time reduced 6x from over 13 minutes to 2 minutes 20 seconds, after converting from Mocha to Jest 23 Beta.

Interactive Snapshot Mode


The newly incorporated Interactive snapshot mode, is added as a default watch menu option. With this new mode, testers can browse through each failing snapshot in each failing suite, and review, update or skip each failed snapshots individually.

Snapshot Property Matchers


Jest now has Snapshot property matchers through which testers can pass properties to the snapshot matcher which specify the structure of the data instead of the specific values. These property matchers are then verified before serializing the matcher type to provide consistent snapshot results across multiple test runs.

Jest Each


Jest 23 features a new jest-each library inspired by mocha-each and Spock Data Tables. This library defines a table of test cases, and then runs a test for each row with the specified column values. Support is provided for both array types and template literals for all flavors of describe and test.

Watch Mode Plugins


The watch mode system now allows adding of custom plugins to watch mode. These watch mode plugins can hook into Jest events and provide custom menu options in the watch mode menu.

Other changes include:

  • Test descriptions and functions are a mandate. Jest 23 will fail tests that do not include both a function and a description.
  • Unlock access to the largest independent learning library in Tech for FREE!
    Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
    Renews at €18.99/month. Cancel anytime
  • Undefined props from React snapshots are now removed.
  • MapCoverage, jest.genMockFunction and jest.genMockFn are deprecated.
  • Snapshot name (if provided) is now added to the snapshot failure message so it's easier to find the snapshot that's failing.
  • Mock timestamps are replaced with invocationCallOrder since two or more mocks may often have the same timestamp, making it impossible to test the call order.
  • Mock function call results are added to snapshots so that both the calls and the results of the invocation are tracked.


For the complete list of changes and updates, see the changelog.

Testing Single Page Applications (SPAs) using Vue.js developer tools
What is React.js and how does it work?
How to test node applications using Mocha framework