返回介绍

Migrating to Jest

发布于 2020-04-21 15:39:30 字数 1757 浏览 1022 评论 0 收藏 0

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).
  • 如果你喜欢 chai,你可以升级Jest并继续使用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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文