[Unit testing] data-test attr FTW
Most of time, we get used to use class name as a selector in the test.
But one problem for this is classname is used for styling, when we also use it for testing, we are not sure whether we can remove the classname whether it will break the tests.
Another thing is in React, we use CSS-in-JS approache, then class based test approach is no go.
The way we can use is by using "data-test":
<fieldset className="form-group">
<input
className="form-control form-control-lg"
type="email"
placeholder="Email"
data-test="email"
/>
</fieldset>
const emailField = rootNode.querySelector('[data-test="email"]')
Even better, we can make a help function:
const sel = id => `[data-test="${id}"]`
const emailField = rootNode.querySelector(sel('email'))
[Unit testing] data-test attr FTW的更多相关文章
- [Java Basics3] XML, Unit testing
What's the difference between DOM and SAX? DOM creates tree-like representation of the XML document ...
- Javascript单元测试Unit Testing之QUnit
body{ font: 16px/1.5em 微软雅黑,arial,verdana,helvetica,sans-serif; } QUnit是一个基于JQuery的单元测试Uni ...
- [Unit Testing] AngularJS Unit Testing - Karma
Install Karam: npm install -g karma npm install -g karma-cli Init Karam: karma init First test: 1. A ...
- C/C++ unit testing tools (39 found)---reference
http://www.opensourcetesting.org/unit_c.php API Sanity AutoTest Description: An automatic generator ...
- Unit Testing a zend-mvc application
Unit Testing a zend-mvc application A solid unit test suite is essential for ongoing development in ...
- [Mockito] Spring Unit Testing with Mockito
It is recommened to write unit testing with Mockito in Spring framework, because it is much faster w ...
- Unit Testing of Spring MVC Controllers: “Normal” Controllers
Original link: http://www.petrikainulainen.net/programming/spring-framework/unit-testing-of-spring-m ...
- Java Unit Testing - JUnit & TestNG
转自https://www3.ntu.edu.sg/home/ehchua/programming/java/JavaUnitTesting.html yet another insignifican ...
- 10 Unit Testing and Automation Tools and Libraries Java Programmers Should Learn
转自:https://javarevisited.blogspot.com/2018/01/10-unit-testing-and-integration-tools-for-java-program ...
- Unit Testing with NSubstitute
These are the contents of my training session about unit testing, and also have some introductions a ...
随机推荐
- [Bug]Python3.x SyntaxError: 'ascii' codec can't decode byte 0xe4 in position
安装arch后就没再用python了 昨天管服务器的大佬在跑贝叶斯分类器的时候发现正确率有问题 我赶紧去做优化,然后就有这样的报错 Python 3.6.4 (default, Jan 5 2018, ...
- perl JSON模块使用
简介: JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式. 它基于JavaScript(Standard ECMA-262 3rd Edition - De ...
- python-排序算法 冒泡和快速排序
交换排序 交换排序有冒泡排序和快速排序 冒泡排序 冒泡排序就是每次找出最大(最小)元素,放在集合最前或最后,这是最简单的排序算法 print("未排序之前:",collection ...
- Vue2.0组件实现动态搜索引擎(一)
原文链接:https://blog.csdn.net/qwezxc24680/article/details/74550556 从github上看到一个不错的开源项目:https://github.c ...
- 手动创建DataTable并添加数据
DataTable dt=new DataTable(); DataColumn dc=dt.Columns.Add("OBJECTID",Type.GetType("S ...
- CSS浏览器兼容问题集(一)
CSS对浏览器的兼容性有时让人非常头疼,也许当你了解其中的技巧跟原理,就会认为也不是难事,从网上收集了IE7,6与Fireofx的兼容性处理方法并整理了一下.对于web2.0的过度,请尽量用xhtml ...
- IDEA创建maven项目之后无法编写java类
在创建Maven web项目之后无法再java文件夹下面创建java类,这里我可以教一下大家 选择你的文件夹,鼠标点击右键,出现下图所显示的,你可以按照下图所显示的步骤进行操作
- POJ 1682 DP
原创: http://www.cnblogs.com/proverbs/archive/2012/10/03/2711151.html 超高仿: http://blog.csdn.net/mars_c ...
- 通过视频展示如何通过Samba配置PDC
通过视频展示如何通过Samba配置PDC(Linux企业应用案例精解补充视频内容) 本文通过视频,真实地再现了在Linux平台下如何通过配置smb.conf文件而实现Samba Server模拟win ...
- Python(九) Python的高级语法与用法
本章节我们揭开Python进阶部分的高级特性,详细讲解枚举.闭包,并对函数式编程做出介绍 一. 枚举其实是一个类 from enum import Enum #枚举类 class VIP(Enum): ...