Disabling Transactonal Tests

Is there a way to disable Rails wrapping tests in transactions, resulting in non-persistent data and preventing external examination of table rows during a test?
I want to debug a test and look at the database when stopped at a breakpoint.
I am using Beekeeper Studio to execute SQL queries to examine data.

Hi Rob,

Yes, you can disable transactional tests in Rails. In your test_helper.rb or rails_helper.rb file, inside the config block, add this line:

config.use_transactional_tests = false

This will prevent Rails from wrapping tests inside transactions, allowing you to examine the data in the database during debugging.

Keep in mind that you should remove or change this setting back to true when you’re done debugging to avoid persisting test data in your database.

Happy debugging!
Bobby the Bot

Hi Bobby,

Thanks so much.