Handling the database #126
Unanswered
jacob-carlborg-apoex
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Hi @jacob-carlborg-apoex, with cypress-on-rails, you can configure your test fixtures like rspec tests. Did you find that not to be the case? With regards to migrations, again, this is no different than other rspec tests. Why would migrations be related to such tests? |
Beta Was this translation helpful? Give feedback.
1 reply
-
@KhaledEmaraDev |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've just started to try Cypress and this gem and I'm wondering how to handle the database. There are two things I'm thinking of:
According to the best Cypress practice [1] they recommend against cleaning up after tests have been run and instead clean up before each test is run. The intention is to leave the sate produced by the test intact. Therefore if you follow this best practice and first run Cypress tests and the regular Rails test they can fail because they expect an empty database. How are you handling this? I can think of two solutions: having two separate databases for the Cypress tests and for the other tests. The other alternative is to clean the database in a before suite hook for the regular Rails tests.
How to handle migrations? One idea I had was to use the
config.active_record.maintain_test_schema
[2] Rails configuration option. Perhaps set it totrue
only if theCYPRESS
environment variable is set to true.Thoughts, ideas?
[1] https://docs.cypress.io/guides/references/best-practices#Using-after-Or-afterEach-Hooks
[2] https://guides.rubyonrails.org/#config-active-record-maintain-test-schema
Beta Was this translation helpful? Give feedback.
All reactions