I've regular RSpec Rails system tests using Capybara/Selenium, like this:
RSpec.describe "Model", type: :system do
context "update model info1" do
# ...
end
context "update model info2" do
# ...
end
context "update model info3" do
# ...
end
# ...
end
If I run these tests individually (e.g. context "update model info1" or context "update model info2") then each of them passes with success.
However, if I run them as a whole from the "root" level (i.e. from RSpec.describe "Model") then some of them fails.
Tests always run sequentially.
What is the problem? How can I make tests to pass with success even when they run as a whole?
If it can be useful, I'm running tests on MacOs Ventura 13.0 with rails 7.0.4.3, rspec-rails 6.0.1, capybara 3.38.0, and selenium-webdriver 4.8.1.
Problems occur because the tested CSS-JS widgets have animations and transitions, which require time... and because my tests do not wait for that time.
The fix is to set the Capybara.disable_animation option to true:
Capybara.disable_animation = true
See also this.