testdouble/cypress-rails

Reconnect when the database gets disconnected

Opened this issue · 0 comments

Sometimes when running a test multiple times with the cypress open IDE, the DB connection will die for whatever reason:

2021-01-11 09:10:42 -0500 Rack app ("POST /test_states/database/projects" - (127.0.0.1)): #<ActiveRecord::StatementInvalid: PG::ConnectionBad: connection is closed>

Rather than kill the process and restart, maybe cypress-rails could detect this and attempt to reconnect?

ActiveRecord::Base.connection.reconnect!