File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,11 @@ This is not supported. Please use \`disableActEnvironment\` to disable the act e
209
209
}
210
210
211
211
export function cleanup ( ) {
212
+ if ( ! mountedRootEntries . length ) {
213
+ // nothing to clean up
214
+ return
215
+ }
216
+
212
217
// there is a good chance this happens outside of a test, where the user
213
218
// has no control over enabling or disabling the React Act environment,
214
219
// so we do it for them here.
@@ -218,13 +223,13 @@ export function cleanup() {
218
223
adjustTestingLibConfig : false ,
219
224
} satisfies /* ensure that all possible options are passed here in case we add more in the future */ Required < DisableActEnvironmentOptions > )
220
225
try {
221
- mountedRootEntries . forEach ( ( { root, container} ) => {
226
+ for ( const { root, container} of mountedRootEntries ) {
222
227
root . unmount ( )
223
228
224
229
if ( container . parentNode === document . body ) {
225
230
document . body . removeChild ( container )
226
231
}
227
- } )
232
+ }
228
233
mountedRootEntries . length = 0
229
234
mountedContainers . clear ( )
230
235
} finally {
You can’t perform that action at this time.
0 commit comments