I am new to cypress and learning it by testing different methods. If any one can help me with the following questions
1.I have learn that most of the cypress object used the jquery objects for DOM but what is exactly the difference between them and what difference it will have in performance? 2.I have used cy.wrap function so i can use should method for the assertion , else i have to use expect method , any leads when to use which one ?? because with then() function i cannot use should method
for cy.wrap , according to cypress documentation the definition is "Invoke the function on the subject in wrap and return the new value" , what exactly the role of cy.wrap is ??
In my sample code below i have used both should() and expect() for assertion
Thanks in advance.
cy.contains('nb-card','Using the Grid').then(firstForm =>{
const emailLabelFirst = firstForm.find('[for="inputEmail1"]').text()
const passwordLabelFirst = firstForm.find('[for="inputPassword2"]').text()
// jquery object assertion is done cia expect method
expect(emailLabelFirst).to.equals('Email')
expect(passwordLabelFirst).to.equals('Password')
cy.contains('nb-card','Basic form').then(secondForm=>{
const passwordLabelSecond = secondForm.find('[for="exampleInputPassword1"]').text()
expect(passwordLabelFirst).to.equal(passwordLabelSecond)
// cy.log('This is test logging message')
// with cypress object assertion is done via should method
cy.wrap(secondForm).find('[for="exampleInputPassword1"]').should('contain','Password')
})
})