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);
});

最新文章

  1. API的非向后兼容性无论如何通常代表着一种比较差的设计
  2. C++拷贝构造函数(深拷贝,浅拷贝)
  3. VC++中,如何定义callback函数和它的触发事件?
  4. 【HDOJ】3652 B-number
  5. .NET垃圾回收与内存泄漏
  6. -_-#【Canvas】回弹
  7. 【转】android电池(五):电池 充电IC(PM2301)驱动分析篇
  8. Android开发中怎样调用系统Email发送邮件(多种调用方式)
  9. NTP时间服务器
  10. Scrum 冲刺 第三日
  11. dedecms给图片加水印覆盖整张图片
  12. PowerDesigner概念(概念数据模型概述)
  13. SQL Server进阶 窗口函数
  14. React项目中实现右键自定义菜单
  15. 关于手贱--npm 误改全局安装路径
  16. 2019.02.15 codechef Favourite Numbers(二分+数位dp+ac自动机)
  17. 修复PLSQL Developer 与 Office 2010的集成导出Excel 功能
  18. 【ATcoder】Xor Sum 2
  19. Java获取系统日期时间
  20. [转]ZooKeeper学习第一期---Zookeeper简单介绍

热门文章

  1. linux下如何使用sftp命令进行文件上传和下载
  2. linux下安装rabbitmq以及在spring中进行集成
  3. (三)Appium-desktop 打包
  4. Elasticsearch之批量操作bulk
  5. CSS中的五大字体家族(cursive 手写字体族更吸引我)
  6. 【java基础】(1)Java的权限修饰符(public,protected,default,private)
  7. android指纹识别、拼图游戏、仿MIUI长截屏、bilibili最美创意等源码
  8. Monad (functional programming)
  9. 视频及MP3 播放浅析 Jplayer参数详细
  10. python中*的用法