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. SQLite进阶-14.子查询

    目录 子查询 SELECT语句中的子查询 INSERT语句中的子查询 UPDATE语句中的子查询 DELETE语句中的子查询 子查询 子查询或内部查询或嵌套查询是在另一个SQLite查询内嵌入在WHE ...

  2. win10使用vnc远程到Ubuntu 19.04

    主要参考:https://www.cyberciti.biz/faq/install-and-configure-tigervnc-server-on-ubuntu-18-04/ https://ww ...

  3. cygwin gcc 编译windowsAPI 报错的一个解决方案

    一开始按照linux的习惯去编译一个使用了windowsAPI的程序 结果提示: $ i686-pc-cygwin-g++ screen_catch.cscreen_catch.c: In funct ...

  4. 使用haystack实现django全文检索搜索引擎功能

    前言 django是python语言的一个web框架,功能强大.配合一些插件可为web网站很方便地添加搜索功能. 搜索引擎使用whoosh,是一个纯python实现的全文搜索引擎,小巧简单. 中文搜索 ...

  5. 并不对劲的CF1245E&F:Cleaning Ladders

    CF1245 E. Hyakugoku and Ladders 题目大意 有一个10 \(\times\) 10的网格,你要按这样的路径行走: 网格中有一些单向传送门,每个传送门连接的两个格子在同一列 ...

  6. Codeforces 1097F. Alex and a TV Show

    传送门 由于只要考虑 $\mod 2$ 意义下的答案,所以我们只要维护一堆的 $01$ 容易想到用 $bitset$ 瞎搞...,发现当复杂度 $qv/32$ 是可以过的... 一开始容易想到对每个集 ...

  7. c# 爬虫和组件HtmlAgilityPack处理html

    测试当前爬虫的User-Agent:http://www.whatismyuseragent.net/ 大佬的博客地址:https://www.cnblogs.com/jjg0519/p/670274 ...

  8. mvc控制器返回操作结果封装

    实体类 public class AjaxResult { /// <summary> /// 获取 Ajax操作结果类型 /// </summary> public Resu ...

  9. 一次解决黑帽SEO的经历

    最近有个朋友跟我说他的网站被黑了,百度快照里显示的是另一个网站,如: 于是查找了些资料,终于找到了问题所在,记录如下: 关于黑帽SEO1.暗链:其实“暗链”就是看不见的网站链接,“暗链”在网站中的链接 ...

  10. JS基础_枚举对象中的属性

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