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

最新文章

  1. 数据泵Expdp和Impdp
  2. WEB框架
  3. JavaScript—之对象参数的引用传递
  4. 【SQL】分享表值函数FMakeRows,用于生成行
  5. BizTalk动手实验(八)消息路由
  6. [Matlab.Matrix] reshape
  7. window.showModalDialog 与window.open传递参数的不同?
  8. shell入门之expr的使用 分类: 学习笔记 linux ubuntu 2015-07-10 14:59 76人阅读 评论(1) 收藏
  9. 1031. Hello World for U (20) PAT
  10. hdu Phone List
  11. LeetCode_Jump Game II
  12. HttpClient---------demo
  13. c# AutoResetEvent和ManualResetEvent
  14. 谈谈单元測试之(二):測试工具 JUnit 3
  15. Django ORM 使用原生 SQL
  16. springboot + schedule
  17. easyui时的时间格式yyyy-MM-dd与yyyy-MM-ddd HH:mm:ss
  18. wtforms-表单生成及验证
  19. P5157 [USACO18DEC]The Cow Gathering
  20. leetcode1018

热门文章

  1. 《Typecript 入门教程》 3、接口
  2. 实战篇之实现 OutLook 中以 EDM 形式发送通知邮件
  3. 【BZOJ2762】[JLOI2011]不等式组(树状数组)
  4. 自己做的一个android 音视频播放器
  5. UNIX环境高级编程--5
  6. Android 8.0 启动后台service 出错 IllegalStateException: Not allowed to start service Intent
  7. android studio 控件提示大写
  8. [入门指南]-技术学习-Ebean
  9. layer:好看的弹出窗口
  10. DDX DDV 用法