- Getting Started
- 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
- 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
- Expect
- Mock Functions
- The Jest Object
- Configuring Jest
- Jest CLI Options
- Globals
文章来源于网络收集而来,版权归原创者所有,如有侵权请及时联系!
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).
- 如果你喜欢 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论