Check inequality of two inputs in Cypress

I have to check whether a variable is less than a constant value in Cypress. How can we achieve this?

e.g: check whether a given variable is less than 30.

1 answer

  • answered 2022-05-04 14:09 agoff

    I'm making a few assumptions here, but, something like the following should work.

    // define constant
    const maxValue = 30;
    cy.get('foo') // get element with variable text
      .then(($el) => { // use the yielded element in a .then()
        // get the text of the element using JQuery's `.text()`
        // and compare the value using Chai's `lessThan`.

    References for inline comments:

    JQuery's text()

    Chai's lessThan (alias for below)

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum