[Cypress] Test Variations of a Feature in Cypress with a data-driven Test
Many applications have features that can be used with slight variations. Instead of maintaining multiple tests with nearly identical code, we can take advantage of the JavaScript runtime and use normal data structures and plain old JavaScript to test and make assertions for multiple interactions in a single test.
we have a new fixture:
// cypress/fixtures/mixed_todos.json [
{ "id": 1, "name": "One", "isComplete": false },
{ "id": 2, "name": "Two", "isComplete": true },
{ "id": 3, "name": "Three", "isComplete": true },
{ "id": 4, "name": "Four", "isComplete": false }
]
In the app, when we click different visibility filter, the list will change accordingly.
To test this behavior in clean code, we can use '.wrap().each()' to test it
it('should Footer todos', function () {
cy.seedAndVisit('fixture:mixed_todos');
const filters = [
{ link: 'Active', expectedLength: 2 },
{ link: 'Completed', expectedLength: 2 },
{ link: 'All', expectedLength: 4 }
];
cy.wrap(filters)
.each(filter => {
// contains(): find the element contains the text
cy.contains(filter.link).click();
cy.get('.todo-list li').should('have.length', filter.expectedLength);
})
});
[Cypress] Test Variations of a Feature in Cypress with a data-driven Test的更多相关文章
- [Cypress] Create Aliases for DOM Elements in Cypress Tests
We’ll often need to access the same DOM elements multiple times in one test. Your first instinct mig ...
- [Cypress] Test React’s Controlled Input with Cypress Selector Playground
React based applications often use controlled inputs, meaning the input event leads to the applicati ...
- [Cypress] Interact with Hidden Elements in a Cypress Test
We often only show UI elements as a result of some user interaction. Cypress detects visibility and ...
- [Cypress] Wait for XHR Responses in a Cypress Test
When testing interactions that require asynchronous calls, we’ll need to wait on responses to make s ...
- [Cypress] Use the Most Robust Selector for Cypress Tests
Which selectors your choose for your tests matter, a lot. In this lesson, we'll see the recommended ...
- Cypress系列(0)- 如何学习 Cypress
如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 前言 Cypress 未来很有可能会火的 ...
- Cypress系列(13)- 详细介绍 Cypress Test Runner
如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 前言 Test Runner 也叫运行器 ...
- 【cypress】2. 安装Cypress(windows系统),以及cypress open报错解决。
安装cypress. 一.操作系统 先确认下你的系统,是否在cypress支持范围之内: macOS 10.9 以上 (仅64-bit) Linux Ubuntu 12.04及以上版本,Fedora ...
- [Cypress] install, configure, and script Cypress for JavaScript web applications -- part4
Load Data from Test Fixtures in Cypress When creating integration tests with Cypress, we’ll often wa ...
随机推荐
- Linux下MySql数据的导入导出
1,每天4点备份mysql数据: 2,为节省空间,删除超过3个月的所有备份数据: 3,删除超过7天的备份数据,保留3个月里的 10号 20号 30号的备份数据: mysqldump -u用戶名 -p密 ...
- NPOI复制模板导出Excel
本人菜鸟实习生一枚,公司给我安排了一个excel导出功能.要求如下:1.导出excel文件有样式要求:2.导出excel包含一个或多个工作表:3.功能做活(我的理解就是excel样式以后可能会变方便维 ...
- 【转】Java 集合系列04之 fail-fast总结(通过ArrayList来说明fail-fast的原理、解决办法)
概要 前面,我们已经学习了ArrayList.接下来,我们以ArrayList为例,对Iterator的fail-fast机制进行了解.内容包括::1 fail-fast简介2 fail-fast示例 ...
- Android项目实战_手机安全卫士流量统计
## 1.抽屉控件SlidingDrawer:一定要配置android:handle(把手)和android:content(内容),并在子View中添加把手和内容的布局```java <Sli ...
- Linux 信息查询
CPU信息查看 #查看CPU型号: $>grep 'model name' /proc/cpuinfo |uniq model name : Intel(R) Xeon(R) CPU ...
- 在CentOS6,CentOS7安装 Let'sEncrypt 免费SSL安全证书
相对来说,个人网站建立SSL是昂贵的,而且往往过程繁琐.一个标准的2048位证书费用至少150美元/年,网站除了要支付一笔昂贵的费用.重新配置Web服务器,并需要解决大量的配置错误.这让广大中小网站望 ...
- 在PHP中调用php_ssh实现远程登陆linux服务器并执行shell脚本。
这个功能主要用于在web端利用程序对远程服务器进行操作,通过PHP_ssh执行shell脚本来实现. 首先要安装php_ssh2组件,linux中centos7下有ssh2源,直接安装.window下 ...
- 我的 Windows 10 的基本配置
Windows 10 的基本配置 功能性 开启 .Net Framework 3.5(包括 .NET 2.0 和 3.0) 旧版本 Windows 10 默认只安装了 .Net Framework 4 ...
- python笔记之发送邮件
发送邮件前提:开启邮箱授权码 一.开启授权码(以163邮箱为例) 1.登录163邮箱,点击设置--POP3/SMTP/IMAP,出现设置界面 2. 开启SMTP服务且可以查询SMTP的host地址 ...
- C# 返回值为 list<T>
public List<T> test<T>(List<T> EntityList) where T : class { return EntityList; }