Jest

Jest

24.1

  • Docs
  • API
  • Help
  • Blog
  • GitHub

›Guides

Introduction

  • Getting Started
  • Using Matchers
  • Testing Asynchronous Code
  • Setup and Teardown
  • Mock Functions
  • Jest Platform
  • Jest Community
  • More Resources

Guides

  • Snapshot Testing
  • An Async Example
  • Timer Mocks
  • Manual Mocks
  • ES6 Class Mocks
  • Bypassing module mocks
  • Using with webpack
  • Using with puppeteer
  • Using with MongoDB
  • DOM Manipulation
  • Watch Plugins
  • Migrating to Jest
  • Troubleshooting
  • Architecture

Framework Guides

  • Testing React Apps
  • Testing React Native Apps
  • Testing Web Frameworks

API Reference

  • Globals
  • Expect
  • Mock Functions
  • The Jest Object
  • Configuring Jest
  • Jest CLI Options

Migrating to Jest

If you'd like to try out Jest with an existing codebase, there are a number of ways to convert to Jest:

  • If you are using Jasmine, or a Jasmine like API (for example Mocha), Jest should be mostly compatible and easy to migrate to.
  • If you are using AVA, Expect.js (by Automattic), Jasmine, Mocha, proxyquire, Should.js or Tape you can automatically migrate with Jest Codemods (see below).
  • If you like chai, you can upgrade to Jest and continue using chai. However, we recommend trying out Jest's assertions and their failure messages. Jest Codemods can migrate from chai (see below).

jest-codemods

If you are using AVA, Chai, Expect.js (by Automattic), Jasmine, Mocha, proxyquire, Should.js or Tape you can use the third-party jest-codemods to do most of the dirty migration work. It runs a code transformation on your codebase using jscodeshift.

Install Jest Codemods with yarn by running:

yarn global add jest-codemods

To transform your existing tests, navigate to the project containing the tests and run:

jest-codemods

More information can be found at https://github.com/skovhus/jest-codemods.

← Watch PluginsTroubleshooting →
Jest
Docs
Getting StartedGuidesAPI Reference
Community
Stack OverflowJest ChatTwitter
More
BlogGitHubStar
Facebook Open Source
Copyright © 2019 Facebook Inc.