A walkthrough on how to mock local storage in Jest tests, as well as how to clear storage in jest tests. Example included.
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 slice with jest in unit tests solution. How to solve new date isostring issue in RTK mock.
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.
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.
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.
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.
Solution for error 'RangeError: timeZone is not supported.' when unit testing Intl API. Caused by Node not supporting time zones
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.