Cheatsheet — Jest

Yuvraj Patil
Jun 15, 2023
Photo by Toon Lambrechts on Unsplash

Mocking

  1. Mock Library methods
React Jest — Mock library methods

2. Partially Mock Library Methods

React Jest — Partially Mock Library Methods

3. Partially Mock Own methods Approach 1

React Jest — Partially Mock own methods

4. Partially Mock Own methods Approach 2

React Jest — Partially Mock Own methods Approach 2

DOM Testing

  1. Shallow Testing with Enzyme
React Jest with Enzyme — Shallow Testing

2. Deep testing with Enzyme

React Jest with Enzyme — Deep Testing

3. DOM Testing with react-native-testing-library

React Jest — DOM Testing with react-native-testing-library

Coverage Report

  1. Generate coverage report in watch mode for all files
yarn testCoverage --watchAll

2. Generate coverage report in watch mode for updated files

yarn testCoverage --changedSince=dev  --watch

3. Generate coverage report in watch mode for a particular file

yarn testCoverage src/feature/dashboard/DashboardScreen.test.tex --watchAll

Sign up to discover human stories that deepen your understanding of the world.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Yuvraj Patil
Yuvraj Patil

Written by Yuvraj Patil

Riding the dragon in realm of React Native. Website: https://.www.yuvrajpatil.com

No responses yet

Write a response