Migrating to Jest

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 Mocha, AVA 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 Mocha, AVA, chai 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 npm by running:

npm install -g 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.

© 2014–present Facebook Inc.
Licensed under the BSD License.
https://facebook.github.io/jest/docs/en/migration-guide.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部