Skip to content

Commit 946045c

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
[Unit] Don't wait for RAF between normal tests
There are still gonna be rafs between test using withMockConnection, withLocal and similar, but there we kinda need it with the way things are currently setup. Bug: 449849125 Change-Id: I0fae30ef1eddafd7e4999950b6b131c816e87541 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7002876 Auto-Submit: Nikolay Vitkov <[email protected]> Reviewed-by: Benedikt Meurer <[email protected]> Commit-Queue: Benedikt Meurer <[email protected]>
1 parent 4644fab commit 946045c

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

front_end/testing/DOMHooks.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff 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');

front_end/testing/MockConnection.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type * as SDK from '../core/sdk/sdk.js';
77
import type {ProtocolMapping} from '../generated/protocol-mapping.js';
88
import type * as ProtocolProxyApi from '../generated/protocol-proxy-api.js';
99

10+
import {raf} from './DOMHelpers.js';
1011
import {cleanTestDOM} from './DOMHooks.js';
1112
import {deinitializeGlobalVars, initializeGlobalVars} from './EnvironmentHelpers.js';
1213
import {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);

front_end/testing/test_setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ beforeEach(async () => {
7777
});
7878

7979
afterEach(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.

0 commit comments

Comments
 (0)