码迷,mamicode.com
首页 > 其他好文 > 详细

[Cypress] Test React’s Controlled Input with Cypress Selector Playground

时间:2018-05-24 21:53:33      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:into   The   ons   ase   bsp   cto   new t   get   puts   

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

标签:into   The   ons   ase   bsp   cto   new t   get   puts   

原文地址:https://www.cnblogs.com/Answer1215/p/9085171.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!