diff --git a/docs/en/guides/testing-async-components.md b/docs/en/guides/testing-async-components.md index c7959b66e..57b349a4c 100644 --- a/docs/en/guides/testing-async-components.md +++ b/docs/en/guides/testing-async-components.md @@ -1,10 +1,10 @@ -# Testing Asynchronous Behavior +# 测试异步行为 -To simplify testing, `vue-test-utils` applies DOM updates _synchronously_. However, there are some techniques you need to be aware of when testing a component with asynchronous behavior such as callbacks or promises. +为了让测试变得简单,`vue-test-utils` _同步_应用 DOM 更新。不过当测试一个带有回调或 Promise 等异步行为的组件时,你需要留意一些技巧。 -One of the most common asynchronous behaviors is API calls and Vuex actions. The following examples shows how to test a method that makes an API call. This example uses Jest to run the test and to mock the HTTP library `axios`. More about Jest manual mocks can be found [here](https://facebook.github.io/jest/docs/en/manual-mocks.html#content). +API 调用和 Vuex action 都是最常见的异步行为之一。下列例子展示了如何测试一个会调用到 API 的方法。这个例子使用 Jest 运行测试用例同时模拟了 HTTP 库 `axios`。更多关于 Jest 的手动模拟的介绍可移步[这里](https://facebook.github.io/jest/docs/en/manual-mocks.html#content)。 -The implementation of the `axios` mock looks like this: +`axios` 的模拟实现大概是这个样子的: ``` js export default { @@ -14,7 +14,7 @@ export default { } ``` -The below component makes an API call when a button is clicked, then assigns the response to `value`. +下面的组件在按钮被点击的时候会调用一个 API,然后将响应的值赋给 `value`。 ``` html