Investigating flakey tests — Run a test loads in rspec by wrapping in a context

Kevin McCarthy
Nov 27, 2022

--

When trying to reproduce flakiness I used to just manually run the test x times from the command line and count how many times it had failed and what the errors were.

Doing it in the code saved me a bunch of time.

# original
it "is tells us it happened" do
user = create(:user)
visit "/"
click_link "make it happen"

expect(page).to have_content "it happened"
end


# run it loads
context "when testing for flakiness" do
20.times do
it "is tells us it happened" do
user = create(:user)
visit "/"
click_link "make it happen"

expect(page).to have_content "it happened"
end
end
end

--

--

No responses yet