ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

Another way to load data

Another option to load data for tests is to use normal rails classes instead of FactoryBot, placed inside of a directory showing the files are for Cypress. I like

# config/application.rb
...
if Rails.env.test?
  cypress_paths = %W(#{config.root}/cypress/app_commands/lib)
  config.eager_load_paths += cypress_paths
  config.autoload_paths += cypress_paths
end

So, in this case, Cypress directory will be added to the load path