File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 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
209209}
210210
211211export function cleanup ( ) {
212+ if ( ! mountedRootEntries . length ) {
213+ // nothing to clean up
214+ return
215+ }
216+
212217 // there is a good chance this happens outside of a test, where the user
213218 // has no control over enabling or disabling the React Act environment,
214219 // so we do it for them here.
@@ -218,13 +223,13 @@ export function cleanup() {
218223 adjustTestingLibConfig : false ,
219224 } satisfies /* ensure that all possible options are passed here in case we add more in the future */ Required < DisableActEnvironmentOptions > )
220225 try {
221- mountedRootEntries . forEach ( ( { root, container} ) => {
226+ for ( const { root, container} of mountedRootEntries ) {
222227 root . unmount ( )
223228
224229 if ( container . parentNode === document . body ) {
225230 document . body . removeChild ( container )
226231 }
227- } )
232+ }
228233 mountedRootEntries . length = 0
229234 mountedContainers . clear ( )
230235 } finally {
You can’t perform that action at this time.
0 commit comments