diff --git a/test/index.js b/test/index.js index 67abc6f..225df13 100644 --- a/test/index.js +++ b/test/index.js @@ -99,7 +99,7 @@ describe('Basic', function() { newButton.textContent = 'Click me too'; const inertContainer = document.querySelector('[inert]'); inertContainer.appendChild(newButton); - // Wait for the next microtask to allow mutation observers to react to the DOM change + // Wait for the next microtask to allow mutation observers to react to the DOM change. Promise.resolve().then(() => { expect(isUnfocusable(newButton)).to.equal(true); done(); @@ -113,7 +113,7 @@ describe('Basic', function() { expect(temp.parentElement).to.eql(fixture); temp.outerHTML = '
'; const div = fixture.querySelector('#inert2'); - // Wait for the next microtask to allow mutation observers to react to the DOM change + // Wait for the next microtask to allow mutation observers to react to the DOM change. Promise.resolve().then(() => { expect(div.inert).to.equal(true); const button = div.querySelector('button'); @@ -155,8 +155,8 @@ describe('Basic', function() { const shadowButton = document.createElement('button'); shadowButton.textContent = 'Shadow button'; host.shadowRoot.appendChild(shadowButton); - // Give time to mutation observers. - setTimeout(function() { + // Wait for the next microtask to allow mutation observers to react to the DOM change. + Promise.resolve().then(() => { expect(isUnfocusable(shadowButton)).to.equal(true); done(); }); @@ -171,8 +171,8 @@ describe('Basic', function() { const shadowButton = document.createElement('button'); shadowButton.textContent = 'Shadow button'; shadowRoot.appendChild(shadowButton); - // Give time to mutation observers. - setTimeout(function() { + // Wait for the next microtask to allow mutation observers to react to the DOM change. + Promise.resolve().then(() => { expect(isUnfocusable(shadowButton)).to.equal(true); done(); }); @@ -233,8 +233,8 @@ describe('Basic', function() { const shadowButton = document.createElement('button'); shadowButton.textContent = 'Shadow button'; host.shadowRoot.appendChild(shadowButton); - // Give time to mutation observers. - setTimeout(function() { + // Wait for the next microtask to allow mutation observers to react to the DOM change. + Promise.resolve().then(() => { expect(isUnfocusable(shadowButton)).to.equal(true); done(); }); @@ -251,8 +251,8 @@ describe('Basic', function() { const shadowButton = document.createElement('button'); shadowButton.textContent = 'Shadow button'; shadowRoot.appendChild(shadowButton); - // Give time to mutation observers. - setTimeout(function() { + // Wait for the next microtask to allow mutation observers to react to the DOM change. + Promise.resolve().then(() => { expect(isUnfocusable(shadowButton)).to.equal(true); done(); });