Testing your application’s behavior when an XHR call results in an error can be difficult. The use of stubs for XHR calls makes it easy for us to setup failure scenarios and ensure that our front-end responds the way we expect. In this lesson, we’ll stub a 500 response for a form submission and verify that our application responds appropriately.

    it('should show an error message for a failed from subission', function () {
const newTodo = "Test";
cy.server();
cy.route({
method: 'POST',
url: '/api/todos',
status: 500,
response: {}
}).as('save'); cy.seedAndVisit(); cy.get('.new-todo')
.type(newTodo)
.type('{enter}'); cy.wait('@save'); cy.get('.todo-list li').should('have.length', 4);
cy.get('.error').should('be.visible');
});

[Cypress] Test XHR Failure Conditions with Cypress的更多相关文章

  1. Cypress系列(5)- 自定义 Cypress

    如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 前言 Cypress 不仅支持用户自定义 ...

  2. [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 ...

  3. Cypress系列(4)- 解析 Cypress 的默认文件结构

    如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 默认文件结构 在使用 cypress o ...

  4. [Cypress] Create True end-to-end Tests with Cypress (Smoke test)

    Integration tests let us keep our tests fast and reliable. They also allow us to test scenarios that ...

  5. [Cypress] Stub Network Requests in a Cypress Test

    To keep our tests fast and easily repeatable, it makes sense to create many integration tests and fe ...

  6. [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 ...

  7. Cypress系列(3)- Cypress 的初次体验

    如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 前言 这里的栗子项目时 Cypress ...

  8. Cypress系列(69)- route() 命令详解

    如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 作用 管理控制整个网络请求 重要注意事项 ...

  9. cypress 端到端测试框架试用

    cypress 包含的特性 端到端测试 集成测试 单元测试 安装 yarn add cypress --dev 运行测试项目 初始化项目 yarn init -y 安装cypress yarn add ...

随机推荐

  1. Python 线程 的 锁

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA9gAAAG7CAYAAAA41T2sAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjw ...

  2. centos源更新

    .备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup .下载新的CentOS-Base.r ...

  3. python自动化测试学习笔记-2-字典、元组、字符串方法

    一.字典 Python字典是另一种可变容器模型,且可存储任意类型对象,如字符串.数字.元组等其他容器模型. 字典的每个键值(key=>value)对用冒号(:)分割,每个对之间用逗号(,)分割, ...

  4. ResGen.exe”已退出,代码为2 问题处理

    转载自  http://blog.sina.com.cn/s/blog_5f82a1060101d8tm.html 在64位的Windows 7下,用VS2010编译4.0以前的.Net项目会有问题. ...

  5. Swift自适应布局(Adaptive Layout)教程

    通用的Storyboard 通用的stroyboard文件是通向自适应布局光明大道的第一步.在一个storyboard文件中适配iPad和iPhone的布局在iOS8中已不再是梦想.我们不必再为不同尺 ...

  6. CentOS配置网卡以及克隆

    上一篇的虚拟机安装完成后是可以上网的,但是ip地址是动态的,因为后期的需要,我们要配置下网卡,改成静态的IP地址 1.打开终端,输入 ifconfig 查看虚拟机中的网卡,发现时ens33而不是平常见 ...

  7. 01--Java集合知识

    一.Java集合概览 Java中集合分2大块,Collection和Map,分别代表不同功能的集合类对象,整体结构图如下: Collection├List│├LinkedList│├ArrayList ...

  8. animation仿进度条

    animation:使用的好可以有很多酷炫效果 仿进度条效果.

  9. SQL基本操作——GROUP BY

    GROUP BY 语句用于结合合计函数,根据一个或多个列对结果集进行分组. SQL GROUP BY 实例:我们拥有下面这个 "Orders" 表 O_Id OrderDate O ...

  10. 2016.01.07 DOM笔记(二) DOM节点

    node节点属性 nodeName属性 oneBox= document.getElementsById('box');var s = oneBox.nodeName;  //nodeName与tag ...