RM

  • Blog

Category: Testing

Tool we love - formbear.io

Ship Forms in 60 Seconds

Stop building form backends. Perfect for MVPs & validating ideas.

Mocking A React Component In Jest

Testing with Jest and React Testing Library

Last Updated: April 28, 2023

A basic overview of testing with Jest and React Testing Library. What are the differences between the two? How should they be used?

How to loop jest unit tests

How to Loop in Jest Unit Tests

Last Updated: November 28, 2022

Sometimes when writing Jest unit tests you are going to want to be able to loop over items to quickly test different cases. Whether this be looping over an array of items, or counting between numbers in your Jest Test....

Mocking local storage in Jest tests

How to Mock Local Storage in Jest tests

Last Updated: November 21, 2022

A walkthrough on how to mock local storage in Jest tests, as well as how to clear storage in jest tests. Example included.

Mock ES6 Module in Jest

How to Mock an ES6 Module Import using Jest

Last Updated: November 21, 2022

How to mock es6 modules? Solution for how ES6 modules can be mocked in Jest unit tests. Mocking es6 modules with Jest.

Mocking date in Redux Toolkit unit tests jest

How to Mock the Date in Redux Toolkit

Last Updated: July 27, 2023

Mocking date in Redux Toolkit slice with jest in unit tests solution. How to solve new date isostring issue in RTK mock.

Arrange Act Assert Unit Test

Arrange, Act and Assert Pattern: The Three A’s of Unit Testing

Last Updated: December 14, 2022

How to use Arrange Act Assert pattern in unit testing, and why it is so helpful. Arrange-Act-Assert is powerful because it is simple. By keeping the tests short and concise means clean tests.

Testing images in React with Jest

Test Images in React with Jest

Last Updated: November 21, 2022

Solution for testing that images have rendered in React using Jest. And how to test an image alt and src in jest using React. Including example code.

Mocking A React Component In Jest

How To Mock A React Component In Jest

Last Updated: December 1, 2022

How to mock a React component in a jest unit test. Example of how to mock a default or named component using React Testing Library.

Use Within to Test in React Testing Library

How to Query and Test Within a Specific Component in Jest

Last Updated: November 21, 2022

Examples of how to use within in Jest and React Testing Library to target a specific section of the component. Restrict Jest queries to a particular element. Inside the context of a DOM node.

Small dog doing React component unit testing

Check React Component Props are Passed to Child in Jest Unit Test

Last Updated: November 21, 2022

How to unit test a React parent component logic, and check that a child component is passed the correct props. Test if a component is called with expected argument using React Testing Library.

Calendar showing one date highlighted for Jest mock article

How to Mock the Date in Jest Consistently

Last Updated: November 21, 2022

Struggling to mock the Date in Jest using CRA? Need consistant global Date testing for React? This article provides the solution.

Lottie and Jest Logos

React Jest Tests Failing Using Lottie.js Solved

Last Updated: September 29, 2022

TypeError: Cannot set property 'fillStyle' of null when using lottie-react in Jest testing solved.

Helpful Bits Straight Into Your Inbox

Subscribe to the newsletter for insights and helpful pieces on React, Next JS, Headless WordPress, and modern web development.

Powered ByFormBear
By Robert Marshall