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

cypress js plugin and vcr integration #103

Merged
merged 6 commits into from
Mar 8, 2022
Merged

Conversation

grantspeelman
Copy link
Collaborator

@grantspeelman grantspeelman commented Mar 8, 2022

Helps with #92

Expermintal Features (matching npm package)

Please test and give feedback

add the npm package:

yarn add cypress-on-rails --dev

for VCR

setup

Add you VCR configuration to your cypress_helper.rb

require 'vcr'
VCR.configure do |config|
  config.hook_into :webmock
end

Add to you cypress/support/index.js

import 'cypress-on-rails/support/index'

Add to you clean.rb

VCR.eject_cassette # make sure we no cassettes inserted before the next test starts

usage

You have vcr_insert_cassette and vcr_eject_cassette available. https://www.rubydoc.info/github/vcr/vcr/VCR:insert_cassette

describe('My First Test', function() {
  beforeEach(() => { cy.app('load_seed') })

  it('visit root', function() {
    cy.app('clean') // have a look at cypress/app_commands/clean.rb

    cy.vcr_insert_cassette('cats', { record: "new_episodes" })
    cy.visit('/using_vcr/index')

    cy.get('a').contains('Cats').click()
    cy.contains('Wikipedia has a recording of a cat meowing, because why not?')

    cy.vcr_eject_cassette();

    cy.vcr_insert_cassette('cats')
    cy.visit('/using_vcr/record_cats')
    cy.contains('Wikipedia has a recording of a cat meowing, because why not?')
  })
})

@grantspeelman grantspeelman mentioned this pull request Mar 8, 2022
@grantspeelman grantspeelman merged commit 17cd554 into master Mar 8, 2022
@grantspeelman grantspeelman deleted the cypress-plugin branch March 8, 2022 05:08
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

Successfully merging this pull request may close these issues.

1 participant