diff --git a/spyder/plugins/editor/widgets/tests/test_folding.py b/spyder/plugins/editor/widgets/tests/test_folding.py
index <HASH>..<HASH> 100644
--- a/spyder/plugins/editor/widgets/tests/test_folding.py
+++ b/spyder/plugins/editor/widgets/tests/test_folding.py
@@ -68,11 +68,11 @@ def test_folding(lsp_codeeditor, qtbot):
     with qtbot.waitSignal(code_editor.lsp_response_signal, timeout=30000):
         code_editor.document_did_change()
 
-    while folding_panel.folding_regions == {}:
-        # This fixes the race condition on the PyLS with the
-        # document_did_change() event
-        with qtbot.waitSignal(code_editor.lsp_response_signal, timeout=30000):
-            code_editor.request_folding()
+    with qtbot.waitSignal(code_editor.lsp_response_signal, timeout=30000):
+        code_editor.request_folding()
+
+    # Wait for the update thread to finish
+    qtbot.wait(2000)
 
     folding_regions = folding_panel.folding_regions
     folding_levels = folding_panel.folding_levels
Add additional wait on test_folding