Jest 中文网

Jest 中文网

  • 中文文档
  • API
  • 帮助
  • Blog
  • GitHub
  • 英文官网

›使用指南

简介

  • 快速入门
  • Using Matchers
  • Testing Asynchronous Code
  • Setup and Teardown
  • Mock Functions
  • Jest Platform
  • Jest Community
  • More Resources

使用指南

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

框架指南

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

API 手册

  • Globals
  • Expect
  • Mock Functions
  • The Jest Object
  • Configuring Jest
  • Jest CLI Options
  • Environment Variables
  • Code Transformation
Edit

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, which makes it less complicated 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.

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

npx jest-codemods

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

← Watch PluginsTroubleshooting →
  • jest-codemods
Jest 中文网
中文文档
快速入门使用指南API 参考手册
社区
Stack OverflowReactifluxTwitter
更多
BlogGitHubStar
友链
Bootstrap中文网ReactNext.jsNuxt.jsBlitz.jsDocusaurusGatsbyWebpackNPMYarn
Facebook Open Source
Copyright © 2020 Facebook Inc.
Jest 项目及相关资源的版权归 Facebook 或项目贡献者所有
Jest 中文文档遵循 MIT 开源协议
京ICP备15031610号-38