博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Cypress] Test React’s Controlled Input with Cypress Selector Playground
阅读量:4608 次
发布时间:2019-06-09

本文共 848 字,大约阅读时间需要 2 分钟。

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);    });

 

转载于:https://www.cnblogs.com/Answer1215/p/9085171.html

你可能感兴趣的文章
CSS常用样式--font
查看>>
恩如氏--蜗牛精华补水蚕丝面膜
查看>>
大工具-收藏
查看>>
codevs3027 线段覆盖 2
查看>>
markdown
查看>>
【leetcode】107-Binary Tree Level Order Traversal II
查看>>
Jquert data方法获取不到数据,显示为undefined。
查看>>
ssm项目中 数据库和资源的备份
查看>>
HDU5950【矩阵快速幂】
查看>>
在线C++编译器
查看>>
C#中各种serialization的比较
查看>>
P2617 Dynamic Rankings
查看>>
工作学习常识1
查看>>
github开发
查看>>
Emacs学习笔记(13):在Emacs中打开pdf
查看>>
flask模板应用-空白控制 --
查看>>
学习过程笔记 7月上
查看>>
ASP.NET WebAPI String 传值问题
查看>>
【2017-3-1】冒泡排序
查看>>
[转载]后缀数组算法总结
查看>>