前端自动化测试会遇上的坑
前端 UI 一直是多变且复杂的题材,经历各种工具迭代与起伏,有很长一段时间其实并没有什么特别统一良好的方式进行测试。在经历过太多次的跌宕变化过后,纪录我认为现阶段怎么打造可被验证的前端与未来趋势与过程中实际遇到的各种困难。
前端 UI 一直是多变且复杂的题材,经历各种工具迭代与起伏,有很长一段时间其实并没有什么特别统一良好的方式进行测试。在经历过太多次的跌宕变化过后,纪录我认为现阶段怎么打造可被验证的前端与未来趋势与过程中实际遇到的各种困难。
前端 UI 一直是多變且複雜的題材,經歷各種工具迭代與起伏,有很長一段時間其實並沒有什麼特別統一良好的方式進行測試。在經歷過太多次的跌宕變化過後,紀錄我認為現階段怎麼打造可被驗證的前端與未來趨勢與過程中實際遇到的各種困難。
Understand the Iterator Protocol and Generator, and arrays benefit from the new iterator helper for lazy evaluation.
之前提到 JavaScript 的 Iterator Protocol:什么让 JavaScript 数据结构能够被迭代? 了解 Iterator Protocol 与 Generator,数组自然受惠于最近推出的 iterator helper 进行惰性求值。
先前提到 JavaScript 的 Iterator Protocol:什麼讓 JavaScript 資料結構能夠被迭代? 了解 Iterator Protocol 與 Generator,而陣列正是基於 iterator 實做,自然受惠於近期推出的 iterator helper 來進行惰性求值。
Have you wondered why arrays can be iterated (for...of) but objects cannot? Iterables rely on the Iterator Protocol to implement iterable data structures.
你有想过为什么阵列可以被迭代处理(for...of)但物件不行吗? Iterables 背后仰赖 Iterator Protocol 来实践可被迭代的资料结构。基于 Iterator Protocol 的概念更是伸展到 Generator Function 相关的知识点,可以创造更多特殊的资料结构。
你有想過為什麼陣列可以被迭代處理(for...of)但物件不行嗎?Iterables 背後仰賴 Iterator Protocol 來實踐可被迭代的資料結構。基於 Iterator Protocol 的概念更是伸展到 Generator Function 相關的知識點,可以創造更多特殊的資料結構。
The benefit of Functor is: it allows us to operate on different "container types" in the same way, preserving the structure while we compute values inside.
Functor 的好处是:它让我们能用同样的方式操作不同的「容器型别」,想像成一个「装值的盒子」,它允许我们对盒子里的值进行运算,但同时又保留了盒子的结构。 Functor 「提供了方式在容器里操作值」,遵循同一性(Identity)与合成性(Composition)。
Functor 的好處是:它讓我們能用同樣的方式操作不同的「容器型別」,想像成一個「裝值的盒子」,它允許我們對盒子裡的值進行運算,但同時又保留了盒子的結構。Functor 「提供了方式在容器裡操作值」,遵循同一性(Identity)與合成性(Composition)。
The `map` of Functor can only operate on values, not "values within a container," necessitating the Applicative Functor.
从先前 Functor 的概念出发,Functor 的 `map` 只能作用在数值上,而不能是「存在于容器中的数值」上,所以才需要 Applicative Functor,一种比 Functor 更多功能的结构,除了满足 Functor 的功能外还能「让盒子里的函数作用(apply)到另一盒子的值」。
從先前 Functor 的概念出發,Functor 的 `map` 只能作用在數值上,而不能是「存在於容器中的數值」上,所以才需要 Applicative Functor,一種比 Functor 更多功能的結構,除了滿足 Functor 的功能外還能「讓盒子裡的函數作用(apply)到另一盒子的值」。
A coding style that emphasizes composing functions rather than handling specific data, defining functions without explicit parameters.