Tests randomly fail when running entire rspec test suite (and don't when run alone) #380
Replies: 9 comments
-
Are you using a parallel runner? See this discussion: and the Integration Tests in the CI section of the guide.
Please provide more information, what is the reason? Try running |
Beta Was this translation helpful? Give feedback.
-
Thanks for the fast reply! I tried setting The only tests that fail seem to be the ones that have two capybara sessions running. So I'm not sure where the problem could be lying. |
Beta Was this translation helpful? Give feedback.
-
This is an example test that fails. The interesting thing is, when I remove the first small test, so the file only has one test, the test passes when running I'm honestly out of ideas. # frozen_string_literal: true
require "rails_helper"
feature "custom questions", :js, type: :feature do
let(:book) { create(:book) }
let(:teacher_license) { create_claimed_license!(role: :teacher, book: book) }
let(:student_license) { create_claimed_license!(book: book) }
let(:class_group) { create(:class_group, name: "klasgroep", teacher_user_book: teacher_license.user_book) }
let(:section) { create(:section, :with_content, content: "definition", book: book) }
let(:section_page) { Page::Section.new(section) }
before do
s(:teacher) { login teacher_license.user }
s(:student) { login student_license.user }
class_group.user_books << student_license.user_book
s(:teacher) { section_page.visit }
s(:student) { section_page.visit }
end
it "cannot be asked when no class group is selected by the teacher" do
s(:teacher) { expect(section_page).to have_no_class_group_selected }
s(:teacher) { expect(section_page.ask_question_button).to be_disabled }
end
context "when teacher has class group selected" do
before do
s(:teacher) { section_page.select_class_group(class_group) }
end
it "can create interaction without any question input" do
s(:teacher) { click_on("Stel een vraag") }
s(:teacher) { click_on("Deel") }
s(:teacher) { expect(section_page).to have_content("Annuleer Vraag") }
s(:student) { expect(section_page).to have_answer_question_button }
s(:student) { section_page.answer_question_button.click }
s(:student) { expect(section_page).to have_content("Verstuur") }
s(:student) { fill_in("answer-input", with: "Leerling antwoord") }
s(:student) { click_on("Verstuur") }
s(:student) { expect(section_page).to have_content("Je antwoord is verzonden!") }
s(:teacher) { expect(section_page).to have_content("Leerling antwoord") }
s(:teacher) { click_on("Annuleer Vraag") }
s(:teacher) { expect(section_page).not_to have_content("Annuleer Vraag") }
s(:student) { expect(section_page).not_to have_answer_question_button }
end
end
def session(name, &block)
Capybara.using_session(name) do
block.call
end
end
alias_method :s, :session
end |
Beta Was this translation helpful? Give feedback.
-
The fact that running a single test works as expected suggests that this is a problem when cleaning up resources, like a hanging Capybara session. Please provide the test failure messages—so far it doesn't seem like this is related with Vite Ruby. |
Beta Was this translation helpful? Give feedback.
-
So I got the tests to work but not quite. When I do However, when I add something like this in my config.before :suite do
puts "\e[31mPrecompiling assets for feature specs \e[0m"
ViteRuby.commands.build
puts "\e[32m-> Finished! precompiling assets for system specs \e[0m"
end there are some tests that fail, where the screenshot is a white page. So I'm assuming there still is a timing/sync issue somewhere? For CI, this isn't really a problem, since we could just the precompile as a step before the tests, but when adding or updating tests, you don't want to have to manually precompile every time. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
No, at least not locally. I haven't tried the tests in CI. |
Beta Was this translation helpful? Give feedback.
-
Seems unusual.
I'd suggest outputting the HTML of that page, or the server response (if any). Moving to Discussions, as it's likely a problem with the integration tests setup. |
Beta Was this translation helpful? Give feedback.
-
So I was able to fix this, it turns out the problem lies at the side of Inertia. When I downgraded from 1.x.x to 0.x.x all my problems disappeard. Very strange and I'm not sure where the combination of Inertia/Vite breaks down but at least I got it working. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
bundle update vite_ruby
.Description 📖
I am trying to migrate a Rails/Inertia application from webpacker to Vite.
So far, everything seems to work except for the tests. When I run the whole test suite tests seem to randomly fail that don't fail when I run them separately. I tested this in the webpacker environment where I did not have this issue.
I tried setting
autoBuild: false
and addingViteRuby.commands.build
to myrails_helper.rb
but that only made other tests fail for some reason.I'm not sure what could be the problem here but I would love to get this to work. Any help would be greatly appreciated.
Reproduction 📖
I cannot really provide a full fledged reproduction but I can tell you the failing tests all use multiple Capybara sessions ( to test interaction).
Run
bin/rake vite:info
and provide the output:Logs 📜
If not providing a reproduction:
Output
Run
DEBUG=vite-plugin-ruby:* bin/vite dev
orDEBUG=vite-plugin-ruby:* bin/vite build
and provide the output:Screenshots 📷
Provide console or browser screenshots of the problem.
Beta Was this translation helpful? Give feedback.
All reactions