File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed
Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,7 @@ function removeCSSEvaluationElement() {
5757 * Completely cleans out the test DOM to ensure it's empty for the next test run.
5858 * This is run automatically between tests - you should not be manually calling this yourself.
5959 **/
60- export const cleanTestDOM = async ( testName = '' ) => {
60+ export const cleanTestDOM = ( testName = '' ) => {
6161 const previousContainer = document . getElementById ( TEST_CONTAINER_ID ) ;
6262 if ( previousContainer ) {
6363 removeChildren ( previousContainer ) ;
@@ -67,8 +67,6 @@ export const cleanTestDOM = async (testName = '') => {
6767 removeTextEditorTooltip ( ) ;
6868 removeAnnouncer ( ) ;
6969 removeCSSEvaluationElement ( ) ;
70- // Make sure all DOM clean up happens before the raf
71- await raf ( ) ;
7270 // Verify that nothing was left behind
7371 for ( const child of document . body . children ) {
7472 if ( ! documentBodyElements . has ( child ) ) {
@@ -92,7 +90,8 @@ export const setupTestDOM = async () => {
9290 // AfterEach hook fails before cleaning the DOM.
9391 // Clean it here and report
9492 console . error ( 'Non clean test state found!' ) ;
95- await cleanTestDOM ( ) ;
93+ cleanTestDOM ( ) ;
94+ await raf ( ) ;
9695 }
9796 // Tests are run in light mode by default.
9897 setColorScheme ( 'light' ) ;
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import type * as SDK from '../core/sdk/sdk.js';
77import type { ProtocolMapping } from '../generated/protocol-mapping.js' ;
88import type * as ProtocolProxyApi from '../generated/protocol-proxy-api.js' ;
99
10+ import { raf } from './DOMHelpers.js' ;
1011import { cleanTestDOM } from './DOMHooks.js' ;
1112import { deinitializeGlobalVars , initializeGlobalVars } from './EnvironmentHelpers.js' ;
1213import { setMockResourceTree } from './ResourceTreeHelpers.js' ;
@@ -136,7 +137,8 @@ async function disable() {
136137 }
137138 // Some Widgets rely on Global vars to be there so they
138139 // can properly remove state once they detach.
139- await cleanTestDOM ( ) ;
140+ cleanTestDOM ( ) ;
141+ await raf ( ) ;
140142 await deinitializeGlobalVars ( ) ;
141143 // @ts -expect-error Setting back to undefined as a hard reset.
142144 ProtocolClient . InspectorBackend . Connection . setFactory ( undefined ) ;
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ beforeEach(async () => {
7777} ) ;
7878
7979afterEach ( async function ( ) {
80- await cleanTestDOM ( this . currentTest ?. fullTitle ( ) ) ;
80+ cleanTestDOM ( this . currentTest ?. fullTitle ( ) ) ;
8181 await checkForPendingActivity ( this . currentTest ?. fullTitle ( ) ) ;
8282 stopTrackingAsyncActivity ( ) ;
8383 // Clear out any Sinon stubs or spies between individual tests.
You can’t perform that action at this time.
0 commit comments