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

256
Views
Jest focus () no es una función

Aquí está mi archivo que tiene un botón para leer más y este botón se enfoca en el elemento

Componente

 ... handleFocusOnText = (): void => { setTimeout(() => this.hiddenTextRef?.focus(), 500) } ... rednder() ... <span ref={(el) => (this.hiddenTextRef = el)} tabIndex={-1} innerHTML={hiddenContent} /> <button data-qa="readmore-expander-button" onClick={this.handleClick} > {this.isOpen ? this.labelLess : this.labelMore} </button>

El método handleClick también llama a handleFocusOnText.

El problema es que hago clic en este botón en mi archivo de prueba y arroja un error de TS de que el enfoque de handleFocusOnText no es una función. ¿Puedes ayudarme con este problema?

Prueba.spec.ts

 .... // Click "read more" button page.doc.querySelector('button').click() await page.waitForChanges() const spanEl = document.querySelector('[data-qa="test-span"]') expect(spanEl).not.toBeNull()
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Me pregunto si esto no está en el contexto correcto. ¿Qué tal si cambiamos

 onClick={this.handleClick}

a

 onClick={() => this.handleClick()}

¿Funcionaría eso?

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!