Skip to content

Commit

Permalink
[#323] - polished 前端/2018-10-29-vue-application-unit-test-strategy-an…
Browse files Browse the repository at this point in the history
…d-practice-02-how-jest-work.md
  • Loading branch information
JimmyLv committed Oct 30, 2018
1 parent b727efd commit 72478ee
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ published: True

在组件化出现之前,我们都压根不谈 UI 的**单元**测试,哪怕是对于 UI 页面层级的测试来说都是一件非常困难的事情。其实**组件化并不全是为了复用,很多情况下也恰恰是为了分治**,从而我们可以分组件对 UI 页面进行开发,然后分别对其进行单元测试。

![](https://o7mw3gkkh.qnssl.com/images/2016/1481267000925.png)
![](https://raw.githubusercontent.com/JimmyLv/images/master/2018/20181030220153.png)

前端组件化已经让 UI 测试变得容易很多,每个组件都可以被简化为这样一个表达式,即 `UI = f(data)`,这个纯函数返回的只是一个描述 UI 组件应该是什么样子的虚拟 DOM,本质上就是一个树形的数据结构。给这个纯函数输入一些应用程序的状态,就会得到相应的 UI 描述的输出,这个过程不会去直接操作实际的 UI 元素,也不会产生所谓的副作用。

Expand Down

0 comments on commit 72478ee

Please sign in to comment.