Requests that aren't stubbed will hit our real backend. To ensure we've stubbed all our routes, we can use the force404 method to send 404s from any unstubbed routes.

By force 404, we can do;

cy.server({ force404: true });

For example:

    cy.server({ force404: true });
cy.get("[data-cy=todo-item-3] > .view > label").dblclick();
cy.get(".edit")
.clear()
.type("update todo{enter}");

It will report 404 for PUT '/api/todos/3/' not found.

So mock it out:

  it("should update todo when dbclick", function() {
cy.server({ force404: true });
cy.route("PUT", "/api/todos/3", "ok").as("updated");
cy.get("[data-cy=todo-item-3] > .view > label").dblclick();
cy.get(".edit")
.clear()
.type("update todo{enter}");
cy.wait("@updated");
});

[Cypress] Find Unstubbed Cypress Requests with Force 404的更多相关文章

  1. 【cypress】6. cypress的默认文件结构介绍

    通过之前的一些介绍,已经大概其明白cypress是个啥,但是具体使用的细节点还有很多,需要一步步的去学习. 在安装好cypress之后,会生成一个默认项目,这个项目结构里的各个文件夹是干嘛使的呢? 一 ...

  2. [Cypress] install, configure, and script Cypress for JavaScript web applications -- part5

    Use the Most Robust Selector for Cypress Tests Which selectors your choose for your tests matter, a ...

  3. 【cypress】3. 编写第一个测试

    当环境安装好了之后,就可以着手尝试第一个测试的编写了. 一.新建一个文件 在你的项目下的cypress/integration文件夹中创建一个新文件sample_spec.js,我这里直接在webst ...

  4. Web前端自动化测试Cypress实践总结

    本文主要首先主要介绍了什么是自动化测试,接着对常用的自动化测试框架进行了对比分析,最后,介绍了如果将自动化测试框架Cypress运用在项目中. 一.自动化测试概述 为了保障软件质量,并减少重复性的测试 ...

  5. e2e测试框架之Cypress

    谈起web自动化测试,大家首先想到的是Selenium!随着近几年前端技术的发展,出现了不少前端测试框架,这些测试框架大多并不依赖于Selenium,这一点跟后端测试框架有很大不同,如Robot Fr ...

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

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

  7. Cypress测试工具

    参考博客:  https://testerhome.com/articles/19035 最近一段时间学习了cypress的测试工具, 她是一个端到端的测试web工具. 环境准备 1.工具:vs co ...

  8. [Cypress] install, configure, and script Cypress for JavaScript web applications -- part3

    Use custom Cypress command for reusable assertions We’re duplicating quite a few commands between th ...

  9. [Cypress] install, configure, and script Cypress for JavaScript web applications -- part1

    Despite the fact that Cypress is an application that runs natively on your machine, you can install ...

随机推荐

  1. MySQL中的触发器应用

    直接上代码: /*数据库 - udi_ems_test*********************************************************************内容:在 ...

  2. easyUI datagrid 刷新取消加载信息 自动刷新闪屏问题

    <style type="text/css"> /*-- 消除grid屏闪问题 --//*/ .datagrid-mask { opacity: 0; filter: ...

  3. MySQL优化 - 性能分析与查询优化(转)

    出处:  MySQL优化 - 性能分析与查询优化 优化应贯穿整个产品开发周期中,比如编写复杂SQL时查看执行计划,安装MySQL服务器时尽量合理配置(见过太多完全使用默认配置安装的情况),根据应用负载 ...

  4. Linux上定时shell脚本

    原文链接:http://www.92coder.com/9-Linux%E5%AE%9A%E6%97%B6shell%E8%84%9A%E6%9C%AC/#more 本文主要介绍在Linux系统上部署 ...

  5. .Net Core项目如何设置静态页面为项目的启动页面?

    最近在使用Core的webApi作为服务器端的数据提供者,但是需要有自己的官网,来指导前端如何使用该接口,因为不想接入MVC这么大的框架,于是写了个静态页面挂上doc文档提供下载就行. 在项目的Sta ...

  6. C++遍历文件夹

    struct _finddata_t { unsigned attrib; //文件属性 time_t time_create; //文件创建时间 time_t time_access; //文件上一 ...

  7. python selenium1 模拟点击 测试对象 58同城验证码

    #!/usr/bin/python# -*- coding: UTF-8 -*-# @Time : 2019/12/5 17:30# @Author : shenghao/10347899@qq.co ...

  8. JS基础_对象的方法

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. SSE指令集加速之 I420转BGR24

    void yuv420_to_rgb24_sse3(uint8_t *yp, uint8_t *up, uint8_t *vp, int sy, int suv, int width, int hei ...

  10. datagrid如何获取选中行的索引

    //datagrid获取选中行 var row =baseSelectgrid.datagrid('getSelected'); // 获取被选中行的索引 index var index=baseSe ...