Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

219
Views
¿Cómo usar la aserción expect().to.match() de Chai-jQuery en Cypress? En su lugar, se utiliza la afirmación BDD con el mismo nombre.

Quiero usar la afirmación Chai-jQuery .match :

 // from Cypress docs: // match(selector) expect($emptyEl).to.match(':empty')

Pero el problema es que existe una afirmación BDD con el mismo nombre:

 // from Cypress docs: // match(RegExp) expect('testing').to.match(/^test/)

Quiero usar el primero, pero no puedo entender cómo, cada vez que se usa la afirmación BDD y arroja un error. Por ejemplo:

 expect(cy.get('div')).to.match('#someId')

match requiere que su argumento sea RegExp. Aprobaste: #someId

Intenté pasar muchas cosas diferentes a la llamada expect() con la esperanza de desencadenar una sobrecarga diferente, pero siempre obtengo este error.

Entonces, ¿qué debo hacer para usar la aserción Chai-jQuery .match ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que Cypress elige la versión .match() del tipo pasado a la parte expect() .

Con este fragmento

 <div id="someId">some text</div>

esto pasará

 cy.get('div').then($el => { expect($el).to.match('#someId') // $el is type object, // so match will be from chai-jQuery expect($el.text()).to.match(/some text/) // $el.text() is type string, // so match will be from chai }) // Same applies with .should() wrapper cy.get('div').should('match', '#someId') cy.get('div').invoke('text').should('match', /some text/)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!