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

87
Views
TypeError in test jest

Hello tries to perform a test of a function, but receives this related error.

 TypeError: Cannot read properties of undefined (reading 'setFocus')

      81 |     this.lastFocusableElement = this.focusableElements[this.focusableElements.length - 1];
      82 |
    > 83 |     this.firstFocusableElement.setFocus();
         |                                        ^
      84 |   }
      85 |
      86 |   private clearFocusableElements(): void {

      at HTMLElement.setFocus (packages/modal/src/modal.ts:83:40)
      at HTMLElement.open (packages/modal/src/modal.ts:63:10)
      at Object.<anonymous> (packages/modal/src/modal.test.ts:102:14)

My Function

 private setFocus(): void {
    this.clearFocusableElements();
    this.findFocusableElements(this.querySelectorAll('*'));
    this.firstFocusableElement =
    this.modalElement.querySelector('.modal-close');
    this.lastFocusableElement = this.focusableElements[this.focusableElements.length - 1];
    this.firstFocusableElement.setFocus();
  }
about 4 years ago · Juan Pablo Isaza
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!