diff --git a/CHANGELOG.md b/CHANGELOG.md
index cf39676..cecf1e4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
### Changed
* Add support for matching npm package and VCR
+* generate for cypress 10 [PR 108](https://github.com/shakacode/cypress-on-rails/pull/108)
## [1.12.1]
[Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.12.0...v1.12.1
diff --git a/README.md b/README.md
index b4147f5..3cc4f3e 100644
--- a/README.md
+++ b/README.md
@@ -71,7 +71,7 @@ bin/rails g cypress_on_rails:update
The generator modifies/adds the following files/directory in your application:
* `config/environments/test.rb`
* `config/initializers/cypress_on_rails` used to configure CypressDev
-* `spec/cypress/integrations/` contains your cypress tests
+* `spec/cypress/e2e/` contains your cypress tests
* `spec/cypress/support/on-rails.js` contains CypressDev support code
* `spec/cypress/app_commands/scenarios/` contains your CypressDev scenario definitions
* `spec/cypress/cypress_helper.rb` contains helper code for CypressDev app commands
@@ -135,7 +135,7 @@ node_modules/.bin/cypress run
You can run your [factory_bot](https://github.com/thoughtbot/factory_bot) directly as well
```js
-// spec/cypress/integrations/simple_spec.js
+// spec/cypress/e2e/simple.cy.js
describe('My First Test', function() {
it('visit root', function() {
// This calls to the backend to prepare the application state
@@ -209,7 +209,7 @@ ActiveRecord::FixtureSet.create_fixtures(fixtures_dir, fixture_files)
```
```js
-// spec/cypress/integrations/simple_spec.js
+// spec/cypress/e2e/simple.cy.js
describe('My First Test', function() {
it('visit root', function() {
// This calls to the backend to prepare the application state
@@ -238,7 +238,7 @@ CypressOnRails::SmartFactoryWrapper.create(:profile, name: "Cypress Hill")
Then reference the scenario in your test:
```js
-// spec/cypress/integrations/scenario_example_spec.js
+// spec/cypress/e2e/scenario_example.cy.js
describe('My First Test', function() {
it('visit root', function() {
// This calls to the backend to prepare the application state
@@ -261,7 +261,7 @@ load "#{Rails.root}/db/seeds.rb"
Then reference the command in your test with `cy.app('load_seed')`:
```js
-// spec/cypress/integrations/simple_spec.js
+// spec/cypress/e2e/simple.cy.js
describe('My First Test', function() {
beforeEach(() => { cy.app('load_seed') })
diff --git a/lib/cypress-on-rails.rb b/lib/cypress-on-rails.rb
index 2473b1e..ec49210 100644
--- a/lib/cypress-on-rails.rb
+++ b/lib/cypress-on-rails.rb
@@ -3,5 +3,5 @@
require_relative './cypress_on_rails/railtie' if defined?(Rails)
# maintain backward compatibility
-CypressDev = CypressOnRails
-Cypress = CypressDev
+CypressDev = CypressOnRails unless defined?(CypressDev)
+Cypress = CypressDev unless defined?(Cypress)
diff --git a/lib/cypress_on_rails/middleware.rb b/lib/cypress_on_rails/middleware.rb
index 96ff611..043ab70 100644
--- a/lib/cypress_on_rails/middleware.rb
+++ b/lib/cypress_on_rails/middleware.rb
@@ -59,6 +59,7 @@ def handle_command(req)
output = {"message" => "Cannot convert to json"}.to_json
end
+ logger.debug "output: #{output}"
[201, {'Content-Type' => 'application/json'}, [output]]
rescue => e
output = {"message" => e.message, "class" => e.class.to_s}.to_json
diff --git a/lib/generators/cypress_on_rails/install_generator.rb b/lib/generators/cypress_on_rails/install_generator.rb
index 4d930a9..43c9138 100644
--- a/lib/generators/cypress_on_rails/install_generator.rb
+++ b/lib/generators/cypress_on_rails/install_generator.rb
@@ -3,7 +3,6 @@ class InstallGenerator < Rails::Generators::Base
class_option :cypress_folder, type: :string, default: 'cypress'
class_option :install_cypress, type: :boolean, default: true
class_option :install_cypress_with, type: :string, default: 'yarn'
- class_option :install_cypress_examples, type: :boolean, default: false
class_option :experimental, type: :boolean, default: false
source_root File.expand_path('../templates', __FILE__)
@@ -23,13 +22,9 @@ def install_cypress
fail 'failed to install cypress' unless system(command)
end
end
- if options.install_cypress_examples
- directory 'spec/cypress/integration/examples', "#{options.cypress_folder}/integration/examples"
- directory 'spec/cypress/fixtures', "#{options.cypress_folder}/fixtures"
- end
template "spec/cypress/support/index.js.erb", "#{options.cypress_folder}/support/index.js"
copy_file "spec/cypress/support/commands.js", "#{options.cypress_folder}/support/commands.js"
- copy_file "spec/cypress.json", "#{options.cypress_folder}/../cypress.json"
+ copy_file "spec/cypress.config.js", "#{options.cypress_folder}/../cypress.config.js"
end
def add_initial_files
@@ -37,7 +32,7 @@ def add_initial_files
template "spec/cypress/cypress_helper.rb.erb", "#{options.cypress_folder}/cypress_helper.rb"
copy_file "spec/cypress/support/on-rails.js", "#{options.cypress_folder}/support/on-rails.js"
directory 'spec/cypress/app_commands', "#{options.cypress_folder}/app_commands"
- directory 'spec/cypress/integration/rails_examples', "#{options.cypress_folder}/integration/rails_examples"
+ directory 'spec/cypress/e2e/rails_examples', "#{options.cypress_folder}/e2e/rails_examples"
end
def update_files
diff --git a/lib/generators/cypress_on_rails/templates/spec/cypress.config.js b/lib/generators/cypress_on_rails/templates/spec/cypress.config.js
new file mode 100644
index 0000000..e1066e5
--- /dev/null
+++ b/lib/generators/cypress_on_rails/templates/spec/cypress.config.js
@@ -0,0 +1,9 @@
+const { defineConfig } = require('cypress')
+
+module.exports = defineConfig({
+ e2e: {
+ baseUrl: "http://localhost:5017",
+ defaultCommandTimeout: 10000,
+ supportFile: "cypress/support/index.js",
+ }
+})
diff --git a/lib/generators/cypress_on_rails/templates/spec/cypress.json b/lib/generators/cypress_on_rails/templates/spec/cypress.json
deleted file mode 100644
index 06d1bf5..0000000
--- a/lib/generators/cypress_on_rails/templates/spec/cypress.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "baseUrl": "http://localhost:5017",
- "defaultCommandTimeout": 10000
-}
diff --git a/lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/advance_factory_bot_spec.js b/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/advance_factory_bot.cy.js
similarity index 100%
rename from lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/advance_factory_bot_spec.js
rename to lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/advance_factory_bot.cy.js
diff --git a/lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/other_spec.js b/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/other.cy.js
similarity index 100%
rename from lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/other_spec.js
rename to lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/other.cy.js
diff --git a/lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/using_factory_bot_spec.js b/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_factory_bot.cy.js
similarity index 100%
rename from lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/using_factory_bot_spec.js
rename to lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_factory_bot.cy.js
diff --git a/lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/using_fixtures_spec.js b/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_fixtures.cy.js
similarity index 100%
rename from lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/using_fixtures_spec.js
rename to lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_fixtures.cy.js
diff --git a/lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/using_scenarios_spec.js b/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_scenarios.cy.js
similarity index 100%
rename from lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/using_scenarios_spec.js
rename to lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_scenarios.cy.js
diff --git a/lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/using_vcr_spec.js b/lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_vcr.cy.js
similarity index 100%
rename from lib/generators/cypress_on_rails/templates/spec/cypress/integration/rails_examples/using_vcr_spec.js
rename to lib/generators/cypress_on_rails/templates/spec/cypress/e2e/rails_examples/using_vcr.cy.js
diff --git a/lib/generators/cypress_on_rails/templates/spec/cypress/fixtures/example.json b/lib/generators/cypress_on_rails/templates/spec/cypress/fixtures/example.json
deleted file mode 100644
index da18d93..0000000
--- a/lib/generators/cypress_on_rails/templates/spec/cypress/fixtures/example.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "name": "Using fixtures to represent data",
- "email": "hello@cypress.io",
- "body": "Fixtures are a great way to mock data for responses to routes"
-}
\ No newline at end of file
diff --git a/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/actions.spec.js b/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/actions.spec.js
deleted file mode 100644
index 0375aba..0000000
--- a/lib/generators/cypress_on_rails/templates/spec/cypress/integration/examples/actions.spec.js
+++ /dev/null
@@ -1,272 +0,0 @@
-///
-
-context('Actions', () => {
- beforeEach(() => {
- cy.visit('https://example.cypress.io/commands/actions')
- })
-
- // https://on.cypress.io/interacting-with-elements
-
- it('.type() - type into a DOM element', () => {
- // https://on.cypress.io/type
- cy.get('.action-email')
- .type('fake@email.com').should('have.value', 'fake@email.com')
-
- // .type() with special character sequences
- .type('{leftarrow}{rightarrow}{uparrow}{downarrow}')
- .type('{del}{selectall}{backspace}')
-
- // .type() with key modifiers
- .type('{alt}{option}') //these are equivalent
- .type('{ctrl}{control}') //these are equivalent
- .type('{meta}{command}{cmd}') //these are equivalent
- .type('{shift}')
-
- // Delay each keypress by 0.1 sec
- .type('slow.typing@email.com', { delay: 100 })
- .should('have.value', 'slow.typing@email.com')
-
- cy.get('.action-disabled')
- // Ignore error checking prior to type
- // like whether the input is visible or disabled
- .type('disabled error checking', { force: true })
- .should('have.value', 'disabled error checking')
- })
-
- it('.focus() - focus on a DOM element', () => {
- // https://on.cypress.io/focus
- cy.get('.action-focus').focus()
- .should('have.class', 'focus')
- .prev().should('have.attr', 'style', 'color: orange;')
- })
-
- it('.blur() - blur off a DOM element', () => {
- // https://on.cypress.io/blur
- cy.get('.action-blur').type('About to blur').blur()
- .should('have.class', 'error')
- .prev().should('have.attr', 'style', 'color: red;')
- })
-
- it('.clear() - clears an input or textarea element', () => {
- // https://on.cypress.io/clear
- cy.get('.action-clear').type('Clear this text')
- .should('have.value', 'Clear this text')
- .clear()
- .should('have.value', '')
- })
-
- it('.submit() - submit a form', () => {
- // https://on.cypress.io/submit
- cy.get('.action-form')
- .find('[type="text"]').type('HALFOFF')
- cy.get('.action-form').submit()
- .next().should('contain', 'Your form has been submitted!')
- })
-
- it('.click() - click on a DOM element', () => {
- // https://on.cypress.io/click
- cy.get('.action-btn').click()
-
- // You can click on 9 specific positions of an element:
- // -----------------------------------
- // | topLeft top topRight |
- // | |
- // | |
- // | |
- // | left center right |
- // | |
- // | |
- // | |
- // | bottomLeft bottom bottomRight |
- // -----------------------------------
-
- // clicking in the center of the element is the default
- cy.get('#action-canvas').click()
-
- cy.get('#action-canvas').click('topLeft')
- cy.get('#action-canvas').click('top')
- cy.get('#action-canvas').click('topRight')
- cy.get('#action-canvas').click('left')
- cy.get('#action-canvas').click('right')
- cy.get('#action-canvas').click('bottomLeft')
- cy.get('#action-canvas').click('bottom')
- cy.get('#action-canvas').click('bottomRight')
-
- // .click() accepts an x and y coordinate
- // that controls where the click occurs :)
-
- cy.get('#action-canvas')
- .click(80, 75) // click 80px on x coord and 75px on y coord
- .click(170, 75)
- .click(80, 165)
- .click(100, 185)
- .click(125, 190)
- .click(150, 185)
- .click(170, 165)
-
- // click multiple elements by passing multiple: true
- cy.get('.action-labels>.label').click({ multiple: true })
-
- // Ignore error checking prior to clicking
- cy.get('.action-opacity>.btn').click({ force: true })
- })
-
- it('.dblclick() - double click on a DOM element', () => {
- // https://on.cypress.io/dblclick
-
- // Our app has a listener on 'dblclick' event in our 'scripts.js'
- // that hides the div and shows an input on double click
- cy.get('.action-div').dblclick().should('not.be.visible')
- cy.get('.action-input-hidden').should('be.visible')
- })
-
- it('.check() - check a checkbox or radio element', () => {
- // https://on.cypress.io/check
-
- // By default, .check() will check all
- // matching checkbox or radio elements in succession, one after another
- cy.get('.action-checkboxes [type="checkbox"]').not('[disabled]')
- .check().should('be.checked')
-
- cy.get('.action-radios [type="radio"]').not('[disabled]')
- .check().should('be.checked')
-
- // .check() accepts a value argument
- cy.get('.action-radios [type="radio"]')
- .check('radio1').should('be.checked')
-
- // .check() accepts an array of values
- cy.get('.action-multiple-checkboxes [type="checkbox"]')
- .check(['checkbox1', 'checkbox2']).should('be.checked')
-
- // Ignore error checking prior to checking
- cy.get('.action-checkboxes [disabled]')
- .check({ force: true }).should('be.checked')
-
- cy.get('.action-radios [type="radio"]')
- .check('radio3', { force: true }).should('be.checked')
- })
-
- it('.uncheck() - uncheck a checkbox element', () => {
- // https://on.cypress.io/uncheck
-
- // By default, .uncheck() will uncheck all matching
- // checkbox elements in succession, one after another
- cy.get('.action-check [type="checkbox"]')
- .not('[disabled]')
- .uncheck().should('not.be.checked')
-
- // .uncheck() accepts a value argument
- cy.get('.action-check [type="checkbox"]')
- .check('checkbox1')
- .uncheck('checkbox1').should('not.be.checked')
-
- // .uncheck() accepts an array of values
- cy.get('.action-check [type="checkbox"]')
- .check(['checkbox1', 'checkbox3'])
- .uncheck(['checkbox1', 'checkbox3']).should('not.be.checked')
-
- // Ignore error checking prior to unchecking
- cy.get('.action-check [disabled]')
- .uncheck({ force: true }).should('not.be.checked')
- })
-
- it('.select() - select an option in a