Skip to content

Commit 6187466

Browse files
authored
Merge pull request #52 from 70data/2.0-cn
22 unit-testing
2 parents 55654e4 + c76af6c commit 6187466

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/guide/unit-testing.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ order: 22
66

77
## 配置和工具
88

9-
Anything compatible with a module-based build system will work, but if you're looking for a specific recommendation, try the [Karma](http://karma-runner.github.io) test runner. It has a lot of community plugins, including support for [Webpack](https://github.com/webpack/karma-webpack) and [Browserify](https://github.com/Nikku/karma-browserify). For detailed setup, please refer to each project's respective documentation, though these example Karma configurations for [Webpack](https://github.com/vuejs/vue-loader-example/blob/master/build/karma.conf.js) and [Browserify](https://github.com/vuejs/vueify-example/blob/master/karma.conf.js) may help you get started.
9+
任何兼容基于模块的构建系统都可以正常使用,但如果你需要一个具体的建议,可以使用[Karma](http://karma-runner.github.io)进行自动化测试。它有很多社区版的插件,包括对[Webpack](https://github.com/webpack/karma-webpack)[Browserify](https://github.com/Nikku/karma-browserify)的支持。更多详细的安装步骤,请参考各项目的安装文档,通过这些Karma配置的例子可以快速帮助你上手([Webpack](https://github.com/vuejs/vue-loader-example/blob/master/build/karma.conf.js)配置,[Browserify](https://github.com/vuejs/vueify-example/blob/master/karma.conf.js)配置)。
1010

1111
## 简单的断言
1212

13-
In terms of code structure for testing, you don't have to do anything special in your components to make them testable. Just export the raw options:
1413
在测试的代码结构方面,你不必在你的组件中做任何特殊的事情使它们可测试。主要导出原始设置就可以了:
1514

1615
``` html
@@ -71,7 +70,7 @@ describe('MyComponent', () => {
7170

7271
## 编写可被测试的组件
7372

74-
A lot of components' render output are primarily determined by the props they receive. In fact, if a component's render output solely depends on its props, it becomes quite straightforward to test, similar to asserting the return value of a pure function with different arguments. Take an contrived example:
73+
很多组件的渲染输出由它的props决定。事实上,如果一个组件的渲染输出完全取决于它的props,那么它会让测试变得简单, 就好像断言不同参数的纯函数的返回值。看下面这个例子:
7574

7675
``` html
7776
<template>
@@ -85,7 +84,7 @@ A lot of components' render output are primarily determined by the props they re
8584
</script>
8685
```
8786

88-
You can assert its render output with different props using the `propsData` option:
87+
你可以在不同的props中,通过 `propsData` 选项断言它的渲染输出:
8988

9089
``` js
9190
import Vue from 'vue'
@@ -129,4 +128,4 @@ it('updates the rendered message when vm.message updates', done => {
129128
})
130129
```
131130

132-
We are planning to work on a collection of common test helpers that makes it even simpler to render components with different constraints (e.g. shallow rendering that ignores child components) and assert their output.
131+
我们计划做一个通用的测试工具集,让不同策略的渲染输出(例如忽略子组件的基本渲染)和断言变得更简单。

0 commit comments

Comments
 (0)