[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 sure we’re asserting about the application state at the right time. With Cypress, we don’t have to use arbitrary time periods to wait. In this lesson, we’ll see how to use an alias for a network request and wait for it to complete without having to wait longer than required or guess at the duration.
Cypress gives us 4 seconds to load the data, but what if the loading time is larger than 4 secods? then test will faild.
To prevent this, we as let Cypress wait unitl one XHR request finish to run the test:
it('should have four initial todos and waiting loaded', function () {
cy.server();
cy.route('GET', '/api/todos', 'fixture:todos')
.as('loadingTodos');
cy.visit('/');
cy.wait('@loadingTodos');
cy.get('.todo-list > li')
.should('have.length', 4);
});
[Cypress] Wait for XHR Responses in a Cypress Test的更多相关文章
- [Cypress] Test XHR Failure Conditions with Cypress
Testing your application’s behavior when an XHR call results in an error can be difficult. The use o ...
- [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 mult ...
- [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] 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] Load Data from Test Fixtures in Cypress
When creating integration tests with Cypress, we’ll often want to stub network requests that respond ...
- [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] 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 也叫运行器 ...
随机推荐
- selenium3 + python3 - alert定位
一.alert\confirm\prompt弹出框操作主要方法有: text:获取文本值 accept() :点击"确认" dismiss() :点击"取消"或 ...
- c#,Java aes加密
1.c#版本 /// <summary> /// Aes加密解密.c#版 /// </summary> public class BjfxEncryptHelper { /// ...
- TCP/IP详解(一)
SYN中的MSS选项是告诉对端,本端在本地连接的每个TCP分节中愿意接收的最大数据量.发送端TCP使用接收端的MSS值作为发送分节的最大大小. TCP半关闭使用的情况较少,可用于通知对端本端数据已输入 ...
- BZOJ 4332 FFT+快速幂
思路: 最裸的方程:f[i][j]=Σf[i-1][j-k]*F[k] 诶呦 这不是卷积嘛 f[i]就可以用f[i-1]卷F 求到 但是这样还是很慢 设p[i] 为Σ f[j](1<=j< ...
- C - Fafa and his Company
Problem description Fafa owns a company that works on huge projects. There are n employees in Fafa's ...
- ORACLE锁表解锁
SELECT object_name, machine, s.sid, s.serial# FROM gv$locked_object l, dba_objects o, gv$session s W ...
- 删除git上已经提交的文件
1.先查看有哪些文件可以删除,但是不真执行删除 git rm -r -n job-executor-common/target/* -r 递归移除目录 -n 加上这个参数,执行命令时,是不会删除任何 ...
- java 基础回顾1
整理----加自己理解------网上参考----- java封装理念 一 概念: 隐藏对象的属性和实现细节,仅供对外提供公共访问方式. 二 好处 1) 将变量隔离 2) 便于使用 3) 提高重 ...
- js-url解析函数
//Url解析 function parseURL(url) { var a = document.createElement('a'); a.href = url; return { source: ...
- snv报错
ERROR svn: E160028: Commit failed svn出现上面错误,先更新再提交即可解决.