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. LA4122

    哈夫曼树+搜索 抄了抄代码 先开始不知道怎么限制哈夫曼树,然后看了看代码,是用bfs序来限制.因为每个节点的右子树节点肯定不小于左儿子,同一层也是.所以先搞出bfs序,然后搜索,判断每一层右边是否大于 ...

  2. PCB MS SQL 将字符串分割为表变量(表值函数)

    Create FUNCTION [dbo].[SplitTable]( @s varchar(max), --待分拆的字符串 ) --数据分隔符 ),), col varchar(max)) --建立 ...

  3. 10.Flask-上下文

    1.1.local线程隔离对象 不用local对象的情况 from threading import Thread request = ' class MyThread(Thread): def ru ...

  4. BZOJ 1303

    思路: 水题  竟然不会做 尴尬 比b大的数=1 比b小的数=-1 找到b 统计一下左边比b大x的数有多少 扫右边的时候就查左边的表 就可以了 //By SiriusRen #include < ...

  5. Git教程(3)git工作区与文件状态及简单示例

    基础 目录: working driectory  工作目录,就是我们的工作目录,其中包括未跟踪文件及暂存区和仓库目录. staging area   暂存区,不对应一个具体目录,其实只是git di ...

  6. WebApi里面路由机制的原理以及路由匹配的过程

    1.WebApi服务启动之后,会执行全局配置文件Global.asax.cs的 protected void Application_Start(){GlobalConfiguration.Confi ...

  7. Safe Area Layout Guide before iOS 9.0

    今天使用Xcode9.1重建项目,什么都没写运行报错:Safe Area Layout Guide before iOS 9.0!目前为止,不晓得原因,现记录解决方法:

  8. SecureCRT连接Ubuntu报The remote system refused the connection.解决方案

    使用SecureCRT连接到远程Ubuntu,连接失败报The remote system refused the connection. 进入Ubuntu系统,终端中敲入以下命令: ps -ef|g ...

  9. 【PostgreSQL-9.6.3】extract函数

    extract函数格式: extract (field from source) extract函数是从日期或者时间数值里面抽取子域,比如年.月.日等.source必须是timestamp.time. ...

  10. SLAM: SLAM的发展历程(WIKI)

    参考维基百科: https://en.wikipedia.org/wiki/Simultaneous_localization_and_mapping 你们叫他SLAM,我还是习惯叫他三维重建.... ...