-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sequence trouble #94
Comments
Yes, I have the same experience when using sequences. Currently we prefer to something like https://github.com/faker-ruby/faker for our factories instead of sequences. Maybe what you could try is in your always_reload: !Rails.configuration.cache_classes, to always_reload: false then in your FactoryBot.reload Let me know if this gives you the desired results. If it does, maybe I'll see about tweaking the code to make this the default. |
Thanks for the quick response!
When I put FactoryBot.reload in
|
can you please give the in your gem 'cypress-on-rails', '~> 1.0', github: 'shakacode/cypress-on-rails', branch: 'factory-bot-sequences' then in your |
I tried it and it works exactly as expected! |
That's great news. I'll get #95 merged 👍🏽 . |
@bendelonlee can you check the log file to see how the factories are getting reloaded. I'll investigate some more in the meantime. |
can you please give the in your gem 'cypress-on-rails', '~> 1.0', github: 'shakacode/cypress-on-rails', branch: 'reload-tweaks' |
I have merged the branch and released a new version. Hopefully this fixes the issue for you 👍🏽 |
👍 I haven't had time to thoroughly test whether the flakiness is gone. Takes time because I wasn't able to reproduce reliably. Thanks for the fix! I'll let you know either way |
Unfortunately I had to remove sequence usage from tests because it wasn't resetting the sequence between tests on CI (though worked locally) and haven't had time to do much further investigation. |
Thanks for creating factory bot cypress!
The Problem
Noticing some unexpected behavior for sequences in a test scenario.
create_list
works as expected:This does not:
It can lead to a lot of boilerplate test setup needing to be added when dealing with items with associations that have uniqueness validators.
My config
My cypress-on-rails version is 1.11.0 (latest).
My factory-bot version is 6.2.
My pretty standard factory_bot.rb
My cypress_helper.rb
My clean.rb
Hack-y solution
I can get desired behavior by adding this to the top of the scenario file:
and this to the bottom:
What hasn't worked
Leaving out
factory.instance.factory::Internal.sequences.clear
makes the sequence not reset between test runs.I tried adding
to clean.rb but it didn't have any effect.
Related issue:
#66 was closed, with a fix.
The text was updated successfully, but these errors were encountered: