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

452
Views
Jest testing : Get Actual height/width of element which are responsive

I have a requirement where I have created HTML bootstrap modal as responsive based on screen resolution and for that, I have used percentage as a unit while setting height/width like below:

<div id="main-popup" class="modal" style="width:500px;height:450px;'>
  <div class="modal-dialog">
    <div class="modal-header" style="width:100%;height:5%"></div>
    <div class="modal-body" style="width:100%;height:90%">
        <div class="left" style="width:25%"></div>
        <div class="right" style="width:75%">
          <table table-hgight="430">
            ....
          </table>
        </div>
    </div>
    <div class="modal-footer" style="width:100%;height:5%"></div>
  </div>
</div>

To make this above popup responsive, I have added the below code in javascript:

$("#main-popup).css('width', '80%');
$("#main-popup).css('height', '75%');
$("#main-popup table").attr("table-height", $("#main-popup).height() * 0.9);

This works perfectly in the application, but in jest testing when I tried to get the actual height/width of those modal elements it's always returning 0. Not sure what I'm missing here.

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!