Skip to content
GitLab
Next
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab FOSS GitLab FOSS
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 1
    • Merge requests 1
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.orgGitLab.org
  • GitLab FOSSGitLab FOSS
  • Issues
  • #33779
Closed
Open
Issue created Jun 16, 2017 by Rémy Coutable@rymai4️⃣Maintainer

Capybara.reset_session! should be called before requests are blocked

capybara/rspec.rb already calls Capybara.reset_sessions! in an after hook, but block_and_wait_for_requests_complete is called before it so by calling it explicitely here, we prevent any new requests from being fired.

I believe, when block_and_wait_for_requests_complete was introduced, it also had the side-effect of not navigating to the blank page anymore prior to blocking any new requests, thus we actually opened the door for different transient failures...

I believe the ultimate solution is as follows:

diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
index c34e76fa72..4aa81a0355 100644
--- a/spec/support/capybara.rb
+++ b/spec/support/capybara.rb
@@ -35,4 +35,13 @@ RSpec.configure do |config|
     TestEnv.eager_load_driver_server
     $capybara_server_already_started = true
   end
+
+  config.after(:each, :js) do
+    Capybara.reset_sessions!
+    block_and_wait_for_requests_complete
+  end
 end
diff --git a/spec/support/wait_for_requests.rb b/spec/support/wait_for_requests.rb
index 1cbe609c0e..d19d01f2d6 100644
--- a/spec/support/wait_for_requests.rb
+++ b/spec/support/wait_for_requests.rb
@@ -53,9 +54,3 @@ module WaitForRequests
     Capybara.current_driver == Capybara.javascript_driver
   end
 end
-
-RSpec.configure do |config|
-  config.after(:each, :js) do
-    block_and_wait_for_requests_complete
-  end
-end
Assignee
Assign to
Time tracking