Skip to content

before_server_stop hook not invoked when CYPRESS_RAILS_TRANSACTIONAL_SERVER=true #161

@theforestvn88

Description

@theforestvn88

Rails 7.1.3.2
Ruby 3.2.2

I setup config as below:

# initializers/cypress_rails.rb

return unless Rails.env.test?

CypressRails.hooks.before_server_start do
   # Called once, before either the transaction or the server is started
   Rails.application.load_tasks
   Rake::Task["db:cypress:seed"].invoke
end

CypressRails.hooks.after_transaction_start do
  # Called after the transaction is started (at launch and after each reset)
end

CypressRails.hooks.after_state_reset do
  # Triggered after `/cypress_rails_reset_state` is called
end

CypressRails.hooks.before_server_stop do
     p "before_server_stop................"
     Rails.application.load_tasks
     Rake::Task["db:truncate_all"].invoke
end

But the before_server_stop hook is not triggered in case there's any test case failed, it looks like there's something wrong with the rollback_transaction, i've not figured out yet. Even i not call the seed rake task on the before_server_start hook , the rollback_transaction is still stucked.

With CYPRESS_RAILS_TRANSACTIONAL_SERVER=false, the before_server_stop hook is triggered.

So i am not sure whether it's a bug or with the config CYPRESS_RAILS_TRANSACTIONAL_SERVER=true we assume that we will not use the before_server_stop hook ? if so, we need to update README.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions