Skip to content
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

before_server_stop hook not invoked when CYPRESS_RAILS_TRANSACTIONAL_SERVER=true #161

Open
theforestvn88 opened this issue May 7, 2024 · 0 comments

Comments

@theforestvn88
Copy link

theforestvn88 commented May 7, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant