メインコンテンツへスキップ
Version: 29.7

Jestへの移行

既存のコードベースで Jestを試してみる場合には、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.
  • AVA、 (Automatticによる) Expect.js 、Jasmine、Mocha、 proxyquire、 Should.js もしくは Tapeを使用している場合、Jest Codemods により自動的に移行することができます(以下を参照して下さい)。
  • If you like chai, you can upgrade to Jest and continue using chai. ただし、Jest のアサーションやエラーメッセージは一度試してみることをオススメします。 Jest Codemods は chai (下記参照) から移行できます。

jest-codemods

If you are using AVA, Chai, Expect.js (by Automattic), Jasmine, Mocha, proxyquire, Should.js, Tape, or Sinon 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.

既存のテストを変換するためにテストを含むプロジェクトに移動し、実行します。

npx jest-codemods

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