jaketrent.com
Testing React on jsdom - Jake Trent
http://www.jaketrent.com/post/testing-react-with-jsdom
Testing React on Jsdom. React allows you to create components that will render UI for your application. If your UI is of any complexity, you’ll likely want to test that it functions correctly and allows for future refactors. There are numerous ways to do this. One way that you might appreciate is using jsdom. An in-JavaScript implementation of the DOM. That means that we can run our tests in environments without browsers, like in Node or in continuous integration environments. The latest version of jsdom.
ifeenan.com
Feenan's Blog-Mocha中文指南-程序人生
http://www.ifeenan.com/javascript/2015-02-26-Mocha中文指南
相比,它有灵活的断言语法,测试提示也比较友好,其它方面跟. Npm install -g mocha. 写的,所以这里重点介绍它的断言语法,更多它的API使用文档,可以 点击这里. 的一个特点,就是它支持友好语法的链式调用,这些语法其实什么都没做,只是编写比较友好,方便阅读,常见的语法有下面这些. Be,an,of,a,and,have,with,is,which,the. 其实没有顺序要求,读起来怎么友好就怎么写,因为它们什么都没做,只是返回. 检查期望的值与真实的值是一样的,当是比较值类型的话,跟`eql`一样,比较引用类型的话, 则要检查两者是否引用同一地址. 检查期望的函数是否会返回异常,方法参数支持异常信息,正则表达式,对象,以便精确匹配错误信息. 999 10 0.1. 检查期望的值是否为空,比如空字符串,空数组,空对象. Mocha -u [bdd tdd exports] *.js. Should return -1 when not present. Should return -1 when not present. Should return -1 when not present.
tech.findmypast.com
Testing React using Enzyme - a novice’s quick guide - Findmypast Tech
http://tech.findmypast.com/testing-react-using-enzyme-novice-guide
Testing React using Enzyme - a novice's quick guide. Testing React using Enzyme - a novice's quick guide. Reading time: 2 min. Writing tests for React components, using Mocha, Enzyme and Should.js, can feel a bit like trying to do this toddlers’ puzzle, inside a black velvet bag. Nope How about this one? Nope Maybe this one? Ok, that seems to work, but - I can’t see the shape it is - so I don’t know why it fitted. Time to learn what is really going on here. Our tests usually look something like this:.
tech.findmypast.com
Testing React using Enzyme - Findmypast Tech
http://tech.findmypast.com/testing-react-using-enzyme
Testing React using Enzyme. Testing React using Enzyme. Reading time: 3 min. It’s a testing utility to assert, manipulate and read rendered React components. Keeps the code base clean and reduced boiler code. Stable rendering of components. Easy to use API to assert on rendered components e.g. What our code looked like before Enzyme. Test asserting the user name exists in the. Function a component is rendered to the dom (using jsdom. The component is removed for clean up and a. There is no need for the.