Use Faker::Lorem.word with caution
Flaky tests are tests that randomly fail. I think it was Oriol who linked an awesome post about them.
As you can imagine, I have flaky tests... and I want to resolve it. Reading some literature about it I've found this:
There are only 249 values in Faker::Lorem::Word collection, so there is a non-trivial chance of collision.
Combined with a uniqueness validation, this could be fatal. The solution is to use it with Factory Bot Sequences:
Instead of:
factory :user do
name { Faker::Lorem.word }
end
Use:
factory :user do
sequence(:name) { |n| "#{Faker::Lorem.word}-#{n}" }
end
Source: https://dev.to/talum/fixing-random-intermittent-and-flaky-rspec-test-failures-56c1 that, by the way, contains this gem:
rspec --seed 1234 --bisect
(no more) Good luck 🤞(required) 🖖