Search code examples
javascriptcypresscontains

Cypress opposite of contains


I code in cypress. Exists something like opposite of cy.contains()? Something like cy.notContains().

I tried:

cy.get('table').should(($table) =>{
            expect($table).to.not.contain("Hello world")
        })

But it does not work. Event if the text wasn't in the table, cypress didn't show any error.

Thank you for your help.


Solution

  • just like this -

    cy.get('table').not('Hello World')
    
    

    Reference