0

I want to use Cypress as a testing tool with the cypress-on-rails plugin.

However during a cypress scenario I want to enable/wrap all rails backend requests with vcr so all requests are captured and replayed.

Typically you would tag a rspec or cucumber file that essentially wraps an entire block of code to perform this. The nature of cypress is that it's completely client/javascript driven and a scenario plays out with multiple ajax requests from the client.

mrzasa
  • 22,895
  • 11
  • 56
  • 94
theog
  • 2,062
  • 2
  • 14
  • 13
  • ...and what do you want to accomplish? – mrzasa Jul 25 '19 at 06:06
  • I want vcr to record all http requests server side for each cypress scenario. Hope that helps. – theog Jul 25 '19 at 06:08
  • 1
    If you could paste code example where you want to add VCR, it'd be really helpful. – mrzasa Jul 25 '19 at 06:12
  • If you're using Cypress, you're jointly testing the front end and back end, so why would you would you want to mock the back end out? Why not just write unit tests? I second what mrzasa is saying; adding code always clarifies questions. fwiw you can do `VCR.use_cassette("my_requests") { ... }` to have VCR save to `"#{config.cassette_library_dir}/my_requests.yml"` – Glyoko Jul 27 '19 at 03:58
  • Please involve in this issue: https://github.com/shakacode/cypress-on-rails/issues/39 – Dmitry Polushkin Dec 05 '19 at 01:19

1 Answers1

0

The insert/eject methods on which the use_cassette method is built are publicly available.

https://www.rubydoc.info/gems/vcr/VCR#insert_cassette-instance_method

VCR.insert_cassette('my_cassette')
# do stuff
VCR.eject_cassette