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

Add initialization hooks #153

Open
Seifeldin7 opened this issue Jan 28, 2024 · 3 comments
Open

Add initialization hooks #153

Seifeldin7 opened this issue Jan 28, 2024 · 3 comments

Comments

@Seifeldin7
Copy link

The cypress-rails gem provides a system of event hooks for loading and reloading test data. An example of these hooks is

CypressOnRails.hooks.before_server_start do
  # Called once, before either the transaction or the server is started
end

We can add hooks similar to those provided by cypress-rails into the cypress-on-rails. They can be useful in certain situations, such as inserting data before the server starts/stops or reloading seeds after state reset using after_state_reset hook.

@grantspeelman
Copy link
Collaborator

@grantspeelman
Copy link
Collaborator

Also your e2e_helper.rb will be loaded on the first request

@Seifeldin7
Copy link
Author

@grantspeelman Kind of, but the difference is

  • Hooks like before_server_start ensures that the command is executed after the rails server is started. I had an issue where I needed to make sure there was some data in the database before the server started. It is relative to the rails server, not cypress. This will also require us to start the server from the gem instead of opening a new terminal.

  • cypress-rails provides a special route cypress_rails_reset_state for resetting the state/ rolling back the transaction to reset the application state before the test is run and after_state_reset hook which is triggered after it, which is different from what we have now with cy.app('clean') which cleans the whole database.

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

No branches or pull requests

2 participants