React based applications often use controlled inputs, meaning the input event leads to the application code setting the value of the very input we’re typing into. Since this moves the input setting behavior into the application code, we should have a test to guard against future changes that might break this behavior. In this lesson, we’ll use the Selector Playground feature in Cypress and create a test that enters text into an input and asserts that the value is the same as the entered text.

The get the selected element, we can use the cypress interface:

    it.only('should type new todo into the input field', function () {
const typedText = 'New todo';
cy.visit('/');
cy.get('.new-todo')
.type(typedText)
.should('have.value', typedText);
});

[Cypress] Test React’s Controlled Input with Cypress Selector Playground的更多相关文章

  1. Cypress系列(13)- 详细介绍 Cypress Test Runner

    如果想从头学起Cypress,可以看下面的系列文章哦 https://www.cnblogs.com/poloyy/category/1768839.html 前言 Test Runner 也叫运行器 ...

  2. react中使用Input表单双向绑定方法

    input react 表单 input 密码框在谷歌浏览器下 会有黄色填充 官网的不太用,这个比较好用 type="password" autoComplete="ne ...

  3. [Cypress] Find and Test Focused Input with Chrome’s DevTools in Cypress

    In this lesson, we’ll add tests that finds a focused input. We’ll use Chrome’s dev tools from inside ...

  4. [React] Make Controlled React Components with Control Props

    Sometimes users of your component want to have more control over what the internal state is. In this ...

  5. [Cypress] Test Variations of a Feature in Cypress with a data-driven Test

    Many applications have features that can be used with slight variations. Instead of maintaining mult ...

  6. [Cypress] Create Aliases for DOM Elements in Cypress Tests

    We’ll often need to access the same DOM elements multiple times in one test. Your first instinct mig ...

  7. [Cypress] Interact with Hidden Elements in a Cypress Test

    We often only show UI elements as a result of some user interaction. Cypress detects visibility and ...

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

  9. [Cypress] Load Data from Test Fixtures in Cypress

    When creating integration tests with Cypress, we’ll often want to stub network requests that respond ...

随机推荐

  1. 排序系列 之 归并排序算法 —— Java实现

    基本思想: 归并排序法是分治法的典型实例,分为分割和归并两部分. 把一个数组分为大小相近的子数组(分割),分别把子数组排好序后,通过合成一个大的排好序的数组(归并). 实例: 先分割成每个子序列只有一 ...

  2. Python 35 线程(2)线程特性、守护线程、线程互斥锁

    一:线程特性介绍 from threading import Thread import time n=100 def task(): global n n=0 if __name__ == '__m ...

  3. thinkphp 上传多张图片

    tp3.23 没有找到同时上传多张图片 手册有讲过:http://www.kancloud.cn/manual/thinkphp/1876 其实可以通过,多张图片多次上传来到达效果 hmlt: < ...

  4. Asp.net MVC4 Step by Step (1)-路由,控制器,视图

    注意:此文需要你有一定Asp.net MVC的基础,很多东西省略了,只是做个提要笔记形式. 要创建一个ASP.NET MVC的Web应用,首先要去下载ASP.NET MVC框架, 可以访问ASP.NE ...

  5. VUE-搜索过滤器

    先看看效果 首先引入 <script src="https://cdn.jsdelivr.net/npm/vue"></script> HTML部分 < ...

  6. python特性小记(一)

    一.关于构造函数和析构函数 1.python中有构造函数和析构函数,和其他语言是一样的.如果子类需要用到父类的构造函数,则需要在子类的构造函数中显式的调用,且如果子类有自己的构造函数,必然不会自动调用 ...

  7. dubbo之直连提供者

    在开发及测试环境下,经常需要绕过注册中心,只测试指定服务提供者,这时候可能需要点对点直连,点对点直联方式,将以服务接口为单位,忽略注册中心的提供者列表,A 接口配置点对点,不影响 B 接口从注册中心获 ...

  8. JDK自带工具

    工具名称 描述 appletviewer.exe 用于运行并浏览applet小程序. apt.exe 注解处理工具(Annotation Processing Tool),主要用于注解处理. extc ...

  9. Visual Studio 推荐插件以及一些设置

    Microsoft Visual Studio 作为微软自家的 IDE 集成 NuGet 包管理器,是的引用一些不同版本组件DLL十分方便. 集成编译环境,强大的 Debug 断点.附加功能 项目模板 ...

  10. 据说现在很缺设计师,阿里云的LOGO是用键盘打出来的……

    今天,阿里云发布了自己的新LOGO,官方的解读是:“[]”这个呢其实是代码中常用的一个符号,代表着计算:中间的“—”则代表流动的数据.在官网等平台上,阿里云新LOGO是动态的,中间的“—”会匀速移动, ...