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. win7下安装memcache

    Windows7 x64在Wamp集成环境下安装Memcache,步骤如下: 1.Memcached-win64 下载 (1)最新版本下载:http://blog.couchbase.com/memc ...

  2. git的常用命令。。

    git的常用命令.. git help <command>  显示command的help git show  显示某次提交的内容 git show $id git co -- <f ...

  3. 知识总结1:debug命令汇总(一)

    -r 得到当前寄存器状态或修改寄存器状态 -d 跳到默认(CS:IP指定的地址)区间 -d 段地址:偏移地址 跳到(段地址*+偏移地址)区间 -d 段地址:起始偏移地址 终止偏移地址 跳到(段地址*+ ...

  4. Djnago进阶

    详情请戳 Cookie和Session及分页设置 Ajax Django中间件 Form和ModelForm组件 auth认证组件 Django 缓存的使用 Django 信号的使用 Django a ...

  5. sql 添加列并设置默认值

    ALTER TABLE tablsename ADD fieldname BIT NULL DEFAULT

  6. SpringMVC参数绑定(二)

    在springMVC中,提交请求的数据是通过方法形参来接收的,从客户端请求的key/value数据,经过参数绑定,将key/value数据绑定到controller形参上,然后再controller就 ...

  7. java多线线程停止正确方法

    //军队线程 //模拟作战双方的行为 public class ArmyRunnable implements Runnable { //volatile保证了线程可以正确的读取其他线程写入的值 // ...

  8. 【sqli-labs】 less1 GET - Error based - Single quotes - String(GET型基于错误的单引号字符型注入)

    GET方式提交id参数 添加单引号,出现报错,爆出数据库名称和部分SQL语句 http://localhost/sqli/Less-1/?id=1' 使用order by猜测字段数,用#注释掉后面li ...

  9. Cache-Control官方文档

    https://tools.ietf.org/html/draft-ietf-httpbis-p6-cache-25#page-21 5.2. Cache-Control The "Cach ...

  10. Swiper 3D flow轮播使用方法

    swiper 的3d轮播效果,移动端适用 (1). 如需使用Swiper的3d切换首先加载3D flow插件(js和css). <head> <link rel="styl ...