cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.

Home Page:https://cypress.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Input number bug impossible to resolve!

MakesCode opened this issue · comments

Current behavior

It is impossible to set a value on an input of type number without the value changing!

Desired behavior

cy.get('[data-testid="coupon-value"] input').should('have.value', value.toString());

Test code to reproduce

<input type="number" data-testid="coupon-value" />
const value = "44"

exemple 1 :

cy.get('[data-testid="coupon-value"] input').clear() // value = 1

exemple 2 :

cy.get('[data-testid="coupon-value"] input').clear().type(value); // value = 441 (44 + clear =1)

exemple 3 :

cy.get('[data-testid="coupon-value"] input')
  .clear() // value = 1
  .invoke('val', value) 
  .trigger('input') 
  .trigger('change') 
// value = 44

cy.wait(4000); // value = 1

Cypress Version

"^12.4.1"

Node version

v22.1.0

Operating System

macOs : 14.2.1

Debug Logs

No response

Other

No response

resolved :
cy.get('[data-testid="coupon-value"] input').clear().type('44{rightArrow}{backspace}')