div id="target" class="container" style="width: 200px;">
  <div class="cell">
    <span></span><span></span><span></span><span></span>
  </div>
  <div class="cell">
    <span></span><span></span><span></span><span></span>
  </div>
</div>
<script>
async function runTest() {
  await new Promise(requestAnimationFrame);
  document.getElementById('target').style.width = '150px';

  await new Promise(requestAnimationFrame);
  takeScreenshot();
}
requestAnimationFrame(() => { requestAnimationFrame(() => runTest())