Mastering Jest: Tips and Tricks for JavaScript Developers

2 ratings

In the ebook, I explain software testing techniques and share tips and tricks I learned while working with Jest on testing multiple Node.js backends and React.js applications.

This ebook is a compilation of curated, short, instructional, and opinionated tips and tricks that explain how you can improve the way you write and maintain your JavaScript tests.

I focus on unit test separation, unique Jest mocking features, creating a maintainable test suite, patterns, and best practices.

It's going to take you about 3 to 4 hours in total to finish all the chapters, but you can also pick only topics that are most interesting for you. Source code for examples is included.

You take no risk with a 30-day money-back guarantee policy! Start learning new skills right now! 🚀

Is this for me?

The ebook is best suited for developers who have some basic experience with unit testing but want to become better, quickly learn a few good practices, and be more fluent with Jest.

What do readers say?

MARIUSZ ŻAK | Full Stack Engineer

OKTAWIAN JURKIEWICZ | JavaScript Developer

The information in this ebook is beneficial for anyone who wants to level up his testing skills. All topics have straightforward description, often taken from the author’s experience. Enjoyed it!

ARTUR ZOCHNIAK | C++, JS, Java Developer

A brief and practical overview of not only basic, but also very advanced features of the Jest testing framework. Full of smart solutions to problems, which are often solved in a crappy and over-complicated way!

What can I learn?

Unit testing - Knowing the testing framework is not enough to write a good unit test. It requires practice so let me share insights, patterns, and best practices.

Jest workflow - Jest is a robust framework, and I explain its most exciting features using examples that will become a valuable reference for you while writing JavaScript unit tests. Understanding Jest CLI is going to make you much faster in working with tests.

Jest matchers - Make your tests more descriptive and easier to read with custom matchers. Write your own or use matchers provided by the community.

Mocking - Mocking is a controversial but powerful tool. Learn how to use it to your advantage, automate mocking or mock only part of the module (yes, you can do that!).

React - Components tests are often a big part of the test suite in my projects. Let me share some tips for when working with React Testing Library.

Table of contents

The ebook consists of easily digestible chapters. Chapters have an introduction and a few short sections, each teaches you about a different topic:

  • Workflow
    - Run only selected tests
    - Skip excluded tests
    - Enter interactive watch mode
    - Check test coverage
    - Debug tests with Node inspector
  • Matchers
    - Decide when to use snapshots
    - Inline snapshots
    - Matching nondeterministic objects
    - Create your own matcher
    - More matchers and chaining
  • Mocking
    - Import mocked modules
    - Mock part of the module
    - Mock implementation with polyfill
    - Automatic and manual mocking
    - Name mocks
    - Clear mocks
  • Usage with React
    - Why react testing library
    - Waiting for changes
    - Avoiding duplication
    - Working with network requests
    - Debugging
    - Element matchers
  • Patterns and best practices
    - Fixtures
    - Page object pattern
    - Control table pattern
    - Property-based testing
    - The shape of testing pyramid

About the author


Hey! 👋 I'm Michal. I work remotely at Hotjar as a Senior Software Engineer and software consultant. My main focus is unit testing and software architecture. I now mostly write code in TypeScript (React/Node.js) and Golang. I maintain a personal blog: Follow me on Twitter, where I share some interesting, bite-size content.

Start learning new skills right now! 🚀


Book + source code

.pdf, .epub, .mobi
Copy product URL


(2 ratings)
5 stars
4 stars
3 stars
2 stars
1 star

Mastering Jest: Tips and Tricks for JavaScript Developers

2 ratings