diff --git a/packages/rrweb/test/integration.test.ts b/packages/rrweb/test/integration.test.ts index d333a40587..5ad10c7fe7 100644 --- a/packages/rrweb/test/integration.test.ts +++ b/packages/rrweb/test/integration.test.ts @@ -117,7 +117,7 @@ describe('record integration tests', function (this: ISuite) { ta2.id = 'ta2'; document.body.append(ta2); }); - await page.waitForTimeout(5); + await waitForRAF(page); await page.evaluate(() => { const t = document.querySelector('textarea') as HTMLTextAreaElement; t.innerText = 'ok'; // this mutation should be recorded @@ -125,16 +125,16 @@ describe('record integration tests', function (this: ISuite) { const ta2t = document.createTextNode('added'); document.getElementById('ta2').append(ta2t); }); - await page.waitForTimeout(5); + await waitForRAF(page); await page.evaluate(() => { const t = document.querySelector('textarea') as HTMLTextAreaElement; (t.childNodes[0] as Text).appendData('3'); // this mutation is also valid document.getElementById('ta2').remove(); // done with this }); - await page.waitForTimeout(5); + await waitForRAF(page); await page.type('textarea', '1'); // types (inserts) at index 0, in front of existing text - await page.waitForTimeout(5); + await waitForRAF(page); await page.evaluate(() => { const t = document.querySelector('textarea') as HTMLTextAreaElement; // user has typed so childNode content should now be ignored @@ -145,7 +145,7 @@ describe('record integration tests', function (this: ISuite) { // there is nothing explicit in rrweb which enforces this, but this test may protect against // a future change where a mutation on a textarea incorrectly updates the .value }); - await page.waitForTimeout(5); + await waitForRAF(page); await page.type('textarea', '2'); // cursor is at index 1 const snapshots = (await page.evaluate( @@ -203,7 +203,7 @@ describe('record integration tests', function (this: ISuite) { ); } }); - await page.waitForTimeout(5); + await waitForRAF(page); await page.evaluate(() => { let styleEl = document.querySelector('style'); if (styleEl) { @@ -218,7 +218,7 @@ describe('record integration tests', function (this: ISuite) { }); } }); - await page.waitForTimeout(5); + await waitForRAF(page); await page.evaluate(() => { let styleEl = document.querySelector('style'); if (styleEl) { @@ -245,16 +245,13 @@ describe('record integration tests', function (this: ISuite) { document.body.append(st); }); - await page.waitForTimeout(5); + await waitForRAF(page); await page.evaluate(() => { let styleEl = document.getElementById('goldilocks'); if (styleEl) { styleEl.childNodes.forEach((cn) => { if (cn.textContent) { - cn.textContent = cn.textContent.replace( - 'brown', - 'gold', - ); + cn.textContent = cn.textContent.replace('brown', 'gold'); } }); }