Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(cn): translate jest/docs/MigrationGuide.md #25

Open
wants to merge 1 commit into
base: cn
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/MigrationGuide.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
---
id: migration-guide
title: Migrating to Jest
title: 迁移至 Jest
---

If you'd like to try out Jest with an existing codebase, there are a number of ways to convert to Jest:
如果你想在现有的代码库中试用 Jest,有很多方法:

- If you are using Jasmine, or a Jasmine like API (for example [Mocha](https://mochajs.org)), 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](http://chaijs.com/), 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).
- 如果你用的是 Jasmine 或者类似 Jasmine API(例如 [Mocha](https://mochajs.org)),Jest 在大多数情况下应该都是兼容的,这使得迁移到 Jest 更简单。
- 如果你用的是 AVAExpect.js( 由 Automattic 提供)、JasmineMochaproxyquireShould.js Tape,则可以使用 Jest Codemods 自动迁移(请参见下文)。
- 如果你喜欢 [chai](http://chaijs.com/),则可以升级到 Jest 并继续使用 chai。但是,我们建议尝试 Jest 的断言及其失败的提示信息。Jest Codemods 可以从 chai 迁移(请参见下文)。

## jest-codemods

If you are using [AVA](https://github.com/avajs/ava), [Chai](https://github.com/chaijs/chai), [Expect.js (by Automattic)](https://github.com/Automattic/expect.js), [Jasmine](https://github.com/jasmine/jasmine), [Mocha](https://github.com/mochajs/mocha), [proxyquire](https://github.com/thlorenz/proxyquire), [Should.js](https://github.com/shouldjs/should.js) or [Tape](https://github.com/substack/tape) you can use the third-party [jest-codemods](https://github.com/skovhus/jest-codemods) to do most of the dirty migration work. It runs a code transformation on your codebase using [jscodeshift](https://github.com/facebook/jscodeshift).
如果你使用的是 [AVA](https://github.com/avajs/ava)[Chai](https://github.com/chaijs/chai)[Expect.js (by Automattic)](https://github.com/Automattic/expect.js)[Jasmine](https://github.com/jasmine/jasmine)[Mocha](https://github.com/mochajs/mocha)[proxyquire](https://github.com/thlorenz/proxyquire) [Should.js](https://github.com/shouldjs/should.js) 或者 [Tape](https://github.com/substack/tape), 那么你可以用第三方的 [jest-codemods](https://github.com/skovhus/jest-codemods) 来完成大部分麻烦的迁移工作。它使用 [jscodeshift](https://github.com/facebook/jscodeshift) 在你的代码库上实现代码转换。

To transform your existing tests, navigate to the project containing the tests and run:
要将现有的测试转换成 Jest,需要在包含测试的项目中运行:

```bash
npx jest-codemods
```

More information can be found at [https://github.com/skovhus/jest-codemods](https://github.com/skovhus/jest-codemods).
更多信息请参见 [https://github.com/skovhus/jest-codemods](https://github.com/skovhus/jest-codemods)