From 92ed2fdd265e1d8cce593194c328475d67222dd3 Mon Sep 17 00:00:00 2001 From: Grant Petersen-Speelman Date: Thu, 4 Jan 2024 13:22:34 +1100 Subject: [PATCH] Update install generator and remove update generator (#149) --- .gitignore | 3 +- CHANGELOG.md | 5 ++ README.md | 47 +++++++------- cypress-on-rails.gemspec | 2 +- .../cypress_on_rails/install_generator.rb | 44 +++++++------ .../initializers/cypress_on_rails.rb.erb | 2 +- .../cypress_on_rails/update_generator.rb | 24 ------- specs_e2e/rails_3_2/test.sh | 21 ++++--- specs_e2e/rails_4_2/.gitignore | 1 + specs_e2e/rails_4_2/package.json | 6 +- .../rails_4_2/playwright-report/index.html | 62 ++++++++++++++++++ .../spec/fixtures/vcr_cassettes/cats.yml | 63 +++++++++++++++++++ specs_e2e/rails_4_2/test.sh | 20 +++--- specs_e2e/rails_5_2/.gitignore | 4 ++ specs_e2e/rails_5_2/test.sh | 23 ++++--- 15 files changed, 228 insertions(+), 99 deletions(-) delete mode 100644 lib/generators/cypress_on_rails/update_generator.rb create mode 100644 specs_e2e/rails_4_2/playwright-report/index.html create mode 100644 specs_e2e/rails_4_2/spec/fixtures/vcr_cassettes/cats.yml diff --git a/.gitignore b/.gitignore index 39ca350..c5a9adb 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ vendor/bundle .vscode node_modules package-lock.json -yarn.lock \ No newline at end of file +yarn.lock +specs_e2e/server.pid diff --git a/CHANGELOG.md b/CHANGELOG.md index b627716..69416a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [Unreleased] + +### Changed +* Removed the update generator and reduced options for install generator [PR 149](https://github.com/shakacode/cypress-on-rails/pull/149) + ## [1.16.0] [Compare]: https://github.com/shakacode/cypress-on-rails/compare/v1.15.1...v1.16.0 diff --git a/README.md b/README.md index 8d5180d..1a3375f 100644 --- a/README.md +++ b/README.md @@ -61,46 +61,43 @@ Generate the boilerplate code using: # by default installs only cypress bin/rails g cypress_on_rails:install -# if you have/want a different cypress folder (default is cypress) -bin/rails g cypress_on_rails:install --cypress_folder=spec/cypress +# if you have/want a different cypress folder (default is e2e) +bin/rails g cypress_on_rails:install --install_folder=spec/cypress -# to install both cypress and playwright -bin/rails g cypress_on_rails:install --install_cypress --install_playwright --playwright_folder=playwright - -# to change where the Ruby files reside (default is e2e) -bin/rails g cypress_on_rails:install --install_folder=test/e2e +# to install playwright instead of cypress +bin/rails g cypress_on_rails:install --framework playwright # if you target the Rails server with a path prefix to your URL bin/rails g cypress_on_rails:install --api_prefix=/api -# if you want to install cypress with npm +# if you want to install with npm instead bin/rails g cypress_on_rails:install --install_with=npm # if you already have cypress installed globally -bin/rails g cypress_on_rails:install --no-install-cypress +bin/rails g cypress_on_rails:install --install_with=skip # to update the generated files run -bin/rails g cypress_on_rails:update +bin/rails g cypress_on_rails:install --install_with=skip ``` The generator modifies/adds the following files/directory in your application: * `config/initializers/cypress_on_rails.rb` used to configure Cypress on Rails -* `spec/cypress/e2e/` contains your cypress tests -* `spec/playwright/e2e/` contains your playwright tests -* `spec/cypress/support/on-rails.js` contains Cypress on Rails support code -* `spec/playwright/support/on-rails.js` contains Playwright on Rails support code -* `spec/e2e/app_commands/scenarios/` contains your Cypress on Rails scenario definitions -* `spec/e2e/cypress_helper.rb` contains helper code for Cypress on Rails app commands +* `e2e/cypress/integration/` contains your cypress tests +* `e2e/cypress/support/on-rails.js` contains Cypress on Rails support code +* `e2e/cypress/e2e_helper.rb` contains helper code to require libraries like factory_bot +* `e2e/cypress/app_commands/` contains your scenario definitions +* `e2e/playwright/e2e/` contains your playwright tests +* `e2e/playwright/support/on-rails.js` contains Playwright on Rails support code -If you are not using `database_cleaner` look at `spec/e2e/app_commands/clean.rb`. -If you are not using `factory_bot` look at `spec/e2e/app_commands/factory_bot.rb`. +If you are not using `database_cleaner` look at `e2e/cypress/app_commands/clean.rb`. +If you are not using `factory_bot` look at `e2e/cypress/app_commands/factory_bot.rb`. Now you can create scenarios and commands that are plain Ruby files that get loaded through middleware, the ruby sky is your limit. ### Update your database.yml -When running `cypress test` or `playwright test` on your local computer it's recommended to start your server in development mode so that changes you -make are picked up without having to restart the server. +When writing and running tests on your local computer it's recommended to start your server in development mode so that changes you +make are picked up without having to restart your local server. It's recommended you update your `database.yml` to check if the `CYPRESS` environment variable is set and switch it to the test database otherwise cypress will keep clearing your development database. @@ -127,11 +124,9 @@ Getting started on your local environment CYPRESS=1 bin/rails server -p 5017 # in separate window start cypress -yarn cypress open +yarn cypress open --project ./e2e # or for npm -node_modules/.bin/cypress open -# or if you changed the cypress folder to spec/cypress -yarn cypress open --project ./spec +npx cypress open --project ./e2e # or for playwright yarn playwright test --ui # or using npm @@ -144,9 +139,9 @@ How to run cypress on CI # setup rails and start server in background # ... -yarn run cypress run +yarn run cypress run --project ./e2e # or for npm -npx cypress run +npx cypress run --project ./e2e ``` ### Example of using factory bot diff --git a/cypress-on-rails.gemspec b/cypress-on-rails.gemspec index 04a1bfc..986ee0f 100644 --- a/cypress-on-rails.gemspec +++ b/cypress-on-rails.gemspec @@ -19,7 +19,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'rake' s.add_development_dependency 'rspec' s.add_development_dependency 'railties', '>= 3.2' - s.add_development_dependency 'factory_bot' + s.add_development_dependency 'factory_bot', '!= 6.4.5' s.add_development_dependency 'vcr' s.metadata = { "bug_tracker_uri" => "https://github.com/shakacode/cypress-on-rails/issues", diff --git a/lib/generators/cypress_on_rails/install_generator.rb b/lib/generators/cypress_on_rails/install_generator.rb index e05a858..e9f4d64 100644 --- a/lib/generators/cypress_on_rails/install_generator.rb +++ b/lib/generators/cypress_on_rails/install_generator.rb @@ -1,12 +1,9 @@ module CypressOnRails class InstallGenerator < Rails::Generators::Base class_option :api_prefix, type: :string, default: '' + class_option :framework, type: :string, default: 'cypress' class_option :install_folder, type: :string, default: 'e2e' - class_option :install_cypress, type: :boolean, default: true - class_option :install_playwright, type: :boolean, default: false class_option :install_with, type: :string, default: 'yarn' - class_option :cypress_folder, type: :string, default: 'cypress' - class_option :playwright_folder, type: :string, default: 'playwright' class_option :experimental, type: :boolean, default: false source_root File.expand_path('../templates', __FILE__) @@ -17,10 +14,11 @@ def install_framework command = nil packages = [] - - packages << 'cypress' if options.install_cypress - packages.push('playwright', '@playwright/test') if options.install_playwright - + packages = if options.framework == 'cypress' + ['cypress', 'cypress-on-rails'] + elsif options.framework == 'playwright' + ['playwright', '@playwright/test'] + end if options.install_with == 'yarn' command = "yarn --cwd=#{install_dir} add #{packages.join(' ')} --dev" elsif options.install_with == 'npm' @@ -31,28 +29,28 @@ def install_framework fail "failed to install #{packages.join(' ')}" unless system(command) end - if options.install_cypress - 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.config.js", "#{options.cypress_folder}/../cypress.config.js" + if options.framework == 'cypress' + template "spec/cypress/support/index.js.erb", "#{options.install_folder}/cypress/support/index.js" + copy_file "spec/cypress/support/commands.js", "#{options.install_folder}/cypress/support/commands.js" + copy_file "spec/cypress.config.js", "#{options.install_folder}/cypress.config.js" end - if options.install_playwright - template "spec/playwright/support/index.js.erb", "#{options.playwright_folder}/support/index.js" - copy_file "spec/playwright.config.js", "#{options.playwright_folder}/../playwright.config.js" + if options.framework == 'playwright' + template "spec/playwright/support/index.js.erb", "#{options.install_folder}/playwright/support/index.js" + copy_file "spec/playwright.config.js", "#{options.install_folder}/playwright.config.js" end end def add_initial_files template "config/initializers/cypress_on_rails.rb.erb", "config/initializers/cypress_on_rails.rb" - template "spec/e2e/e2e_helper.rb.erb", "#{options.install_folder}/e2e_helper.rb" - directory 'spec/e2e/app_commands', "#{options.install_folder}/app_commands" - if options.install_cypress - copy_file "spec/cypress/support/on-rails.js", "#{options.cypress_folder}/support/on-rails.js" - directory 'spec/cypress/e2e/rails_examples', "#{options.cypress_folder}/e2e/rails_examples" + template "spec/e2e/e2e_helper.rb.erb", "#{options.install_folder}/#{options.framework}/e2e_helper.rb" + directory 'spec/e2e/app_commands', "#{options.install_folder}/#{options.framework}/app_commands" + if options.framework == 'cypress' + copy_file "spec/cypress/support/on-rails.js", "#{options.install_folder}/cypress/support/on-rails.js" + directory 'spec/cypress/e2e/rails_examples', "#{options.install_folder}/cypress/e2e/rails_examples" end - if options.install_playwright - copy_file "spec/playwright/support/on-rails.js", "#{options.playwright_folder}/support/on-rails.js" - directory 'spec/playwright/e2e/rails_examples', "#{options.playwright_folder}/e2e/rails_examples" + if options.framework == 'playwright' + copy_file "spec/playwright/support/on-rails.js", "#{options.install_folder}/playwright/support/on-rails.js" + directory 'spec/playwright/e2e/rails_examples', "#{options.install_folder}/playwright/e2e/rails_examples" end end diff --git a/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb b/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb index aa75b40..77bd389 100644 --- a/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb +++ b/lib/generators/cypress_on_rails/templates/config/initializers/cypress_on_rails.rb.erb @@ -1,7 +1,7 @@ if defined?(CypressOnRails) CypressOnRails.configure do |c| c.api_prefix = "<%= options.api_prefix %>" - c.install_folder = File.expand_path("#{__dir__}/../../<%= options.install_folder %>") + c.install_folder = File.expand_path("#{__dir__}/../../<%= options.install_folder %>/<%= options.framework %>") # WARNING!! CypressOnRails can execute arbitrary ruby code # please use with extra caution if enabling on hosted servers or starting your local server on 0.0.0.0 c.use_middleware = !Rails.env.production? diff --git a/lib/generators/cypress_on_rails/update_generator.rb b/lib/generators/cypress_on_rails/update_generator.rb deleted file mode 100644 index 067e07a..0000000 --- a/lib/generators/cypress_on_rails/update_generator.rb +++ /dev/null @@ -1,24 +0,0 @@ -module CypressOnRails - class UpdateGenerator < Rails::Generators::Base - class_option :install_folder, type: :string, default: 'spec/e2e' - class_option :install_cypress, type: :boolean, default: true - class_option :install_playwright, type: :boolean, default: false - class_option :install_with, type: :string, default: 'yarn' - class_option :cypress_folder, type: :string, default: 'spec/cypress' - class_option :playwright_folder, type: :string, default: 'spec/playwright' - source_root File.expand_path('../templates', __FILE__) - - def update_generated_files - template "config/initializers/cypress_on_rails.rb.erb", "config/initializers/cypress_on_rails.rb" - template "spec/e2e/e2e_helper.rb.erb", "#{options.install_folder}/e2e_helper.rb" - directory 'spec/e2e/app_commands', "#{options.install_folder}/app_commands" - - if options.install_cypress - copy_file "spec/cypress/support/on-rails.js", "#{options.cypress_folder}/support/on-rails.js" - end - if options.install_playwright - copy_file "spec/playwright/support/on-rails.js", "#{options.playwright_folder}/support/on-rails.js" - end - end - end -end diff --git a/specs_e2e/rails_3_2/test.sh b/specs_e2e/rails_3_2/test.sh index 4660255..918a736 100755 --- a/specs_e2e/rails_3_2/test.sh +++ b/specs_e2e/rails_3_2/test.sh @@ -10,19 +10,20 @@ export BUNDLE_GEMFILE="$DIR/Gemfile" cd $DIR echo '-- bundle install' -bundle --version -bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2 --path vendor/bundle +gem install bundler -v '1.0.22' +bundle _1.0.22_ --version +bundle _1.0.22_ install --quiet --gemfile="$DIR/Gemfile" --path vendor/bundle echo '-- cypress install' -bundle exec ./bin/rails g cypress_on_rails:install --install_cypress --install_playwright --install_with=npm +bundle exec ./bin/rails g cypress_on_rails:install --install_with=npm --install_folder="." --force rm -vf cypress/e2e/rails_examples/advance_factory_bot.cy.js rm -vf cypress/e2e/rails_examples/using_vcr.cy.js echo '-- start rails server' # make sure the server is not running -(kill -9 `cat tmp/pids/server.pid` || true ) +(kill -9 `cat ../server.pid` || true ) -bundle exec ./bin/rails server -p 5017 -e test & +bundle exec ./bin/rails server -p 5017 -e test -P ../server.pid & sleep 2 # give rails a chance to start up correctly echo '-- cypress run' @@ -31,13 +32,19 @@ cp -fv ../cypress.config.js . # then # node_modules/.bin/cypress run # else - node_modules/.bin/cypress run --record + npx cypress run --record # fi +echo '-- playwright install' +bundle exec ./bin/rails g cypress_on_rails:install --framework playwright --install_with=npm --install_folder="." --force +rm -vf playwright/e2e/rails_examples/advance_factory_bot.cy.js +rm -vf playwright/e2e/rails_examples/using_vcr.cy.js + echo '-- playwright run' cp -fv ../playwright.config.js . npx playwright install-deps +npx playwright install npx playwright test playwright/e2e/ echo '-- stop rails server' -kill -9 `cat tmp/pids/server.pid` +kill -9 `cat ../server.pid` || true diff --git a/specs_e2e/rails_4_2/.gitignore b/specs_e2e/rails_4_2/.gitignore index 9a4f60f..e30f11c 100644 --- a/specs_e2e/rails_4_2/.gitignore +++ b/specs_e2e/rails_4_2/.gitignore @@ -4,6 +4,7 @@ spec/cypress.config.js spec/package.json spec/yarn.lock spec/cypress +spec/app_commands config/initializers/cypress_on_rails.rb vendor/bundle tmp/pids diff --git a/specs_e2e/rails_4_2/package.json b/specs_e2e/rails_4_2/package.json index 14fe886..612aba8 100644 --- a/specs_e2e/rails_4_2/package.json +++ b/specs_e2e/rails_4_2/package.json @@ -4,7 +4,9 @@ "main": "index.js", "license": "MIT", "devDependencies": { - "cypress": "^10.0.2", - "cypress-on-rails": "file:../../plugin" + "@playwright/test": "^1.40.1", + "cypress": "^10.11.0", + "cypress-on-rails": "file:../../plugin", + "playwright": "^1.40.1" } } diff --git a/specs_e2e/rails_4_2/playwright-report/index.html b/specs_e2e/rails_4_2/playwright-report/index.html new file mode 100644 index 0000000..d069452 --- /dev/null +++ b/specs_e2e/rails_4_2/playwright-report/index.html @@ -0,0 +1,62 @@ + + + + + + + + + Playwright Test Report + + + + +
+ + + + \ No newline at end of file diff --git a/specs_e2e/rails_4_2/spec/fixtures/vcr_cassettes/cats.yml b/specs_e2e/rails_4_2/spec/fixtures/vcr_cassettes/cats.yml new file mode 100644 index 0000000..8626b3f --- /dev/null +++ b/specs_e2e/rails_4_2/spec/fixtures/vcr_cassettes/cats.yml @@ -0,0 +1,63 @@ +--- +http_interactions: +- request: + method: get + uri: https://cat-fact.herokuapp.com/facts + body: + encoding: US-ASCII + string: '' + headers: + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + Host: + - cat-fact.herokuapp.com + response: + status: + code: 200 + message: OK + headers: + Server: + - Cowboy + Report-To: + - '{"group":"heroku-nel","max_age":3600,"endpoints":[{"url":"https://nel.heroku.com/reports?ts=1704261545&sid=929419e7-33ea-4e2f-85f0-7d8b7cd5cbd6&s=OabIZbJae2naQpkmA6oM8tyC0dn4yWUtvOVjuyytaRg%3D"}]}' + Reporting-Endpoints: + - heroku-nel=https://nel.heroku.com/reports?ts=1704261545&sid=929419e7-33ea-4e2f-85f0-7d8b7cd5cbd6&s=OabIZbJae2naQpkmA6oM8tyC0dn4yWUtvOVjuyytaRg%3D + Nel: + - '{"report_to":"heroku-nel","max_age":3600,"success_fraction":0.005,"failure_fraction":0.05,"response_headers":["Via"]}' + Connection: + - keep-alive + X-Powered-By: + - Express + Access-Control-Allow-Origin: + - "*" + Content-Type: + - application/json; charset=utf-8 + Content-Length: + - '1877' + Etag: + - W/"755-h8iGk8b461dj2B2tvSoMjrc8cAA" + Set-Cookie: + - connect.sid=s%3ASQfrvsPQGDLjbr1QrsrgV8BwZQptae4i.6BlC7zySZLgqSg%2BRmO6edW%2FxM6WR%2FJ9Xz2lD16D4nWo; + Path=/; HttpOnly + Date: + - Wed, 03 Jan 2024 05:59:05 GMT + Via: + - 1.1 vegur + body: + encoding: UTF-8 + string: '[{"status":{"verified":true,"sentCount":1},"_id":"58e00b5f0aac31001185ed24","user":"58e007480aac31001185ecef","text":"When + asked if her husband had any hobbies, Mary Todd Lincoln is said to have replied + \"cats.\"","__v":0,"source":"user","updatedAt":"2020-08-23T20:20:01.611Z","type":"cat","createdAt":"2018-02-19T21:20:03.434Z","deleted":false,"used":false},{"status":{"verified":true,"feedback":"","sentCount":1},"_id":"5887e1d85c873e0011036889","user":"5a9ac18c7478810ea6c06381","text":"Cats + make about 100 different sounds. Dogs make only about 10.","__v":0,"source":"user","updatedAt":"2020-09-03T16:39:39.578Z","type":"cat","createdAt":"2018-01-15T21:20:00.003Z","deleted":false,"used":true},{"status":{"verified":true,"sentCount":1},"_id":"58e008780aac31001185ed05","user":"58e007480aac31001185ecef","text":"Owning + a cat can reduce the risk of stroke and heart attack by a third.","__v":0,"source":"user","updatedAt":"2020-08-23T20:20:01.611Z","type":"cat","createdAt":"2018-03-29T20:20:03.844Z","deleted":false,"used":false},{"status":{"verified":true,"sentCount":1},"_id":"58e009390aac31001185ed10","user":"58e007480aac31001185ecef","text":"Most + cats are lactose intolerant, and milk can cause painful stomach cramps and + diarrhea. It''s best to forego the milk and just give your cat the standard: + clean, cool drinking water.","__v":0,"source":"user","updatedAt":"2020-08-23T20:20:01.611Z","type":"cat","createdAt":"2018-03-04T21:20:02.979Z","deleted":false,"used":false},{"status":{"verified":true,"sentCount":1},"_id":"58e00af60aac31001185ed1d","user":"58e007480aac31001185ecef","text":"It + was illegal to slay cats in ancient Egypt, in large part because they provided + the great service of controlling the rat population.","__v":0,"source":"user","updatedAt":"2020-09-16T20:20:04.164Z","type":"cat","createdAt":"2018-01-15T21:20:02.945Z","deleted":false,"used":true}]' + recorded_at: Wed, 03 Jan 2024 05:59:06 GMT +recorded_with: VCR 6.0.0 diff --git a/specs_e2e/rails_4_2/test.sh b/specs_e2e/rails_4_2/test.sh index 4d55509..24cfba2 100755 --- a/specs_e2e/rails_4_2/test.sh +++ b/specs_e2e/rails_4_2/test.sh @@ -14,15 +14,15 @@ gem install bundler -v "~> 1.0" --conservative bundle --version bundle install --quiet --gemfile="$DIR/Gemfile" --retry 2 --path vendor/bundle -echo '-- cypress and playwright install' -bundle exec ./bin/rails g cypress_on_rails:install --install_folder=spec/e2e --cypress_folder=spec/cypress --playwright_folder=spec/playwright --install_cypress --install_playwright --experimental --install_with=npm --skip +echo '-- cypress install' +bundle exec ./bin/rails g cypress_on_rails:install --install_folder=spec --framework cypress --experimental --install_with=npm --force rm -vf spec/cypress/e2e/rails_examples/advance_factory_bot.cy.js echo '-- start rails server' # make sure the server is not running -(kill -9 `cat tmp/pids/server.pid` || true ) +(kill -9 `cat ../server.pid` || true ) -bundle exec ./bin/rails server -p 5017 -e test & +bundle exec ./bin/rails server -p 5017 -e test -P ../server.pid & sleep 5 # give rails a chance to start up correctly echo '-- cypress run' @@ -31,14 +31,20 @@ cp -fv ../cypress.config.js spec/ # then # npx cypress run -P ./spec # else - npx cypress run -P ./spec --record + npx cypress install + npx cypress run -P ./spec # --record # fi +echo '-- playwright install' +bundle exec ./bin/rails g cypress_on_rails:install --install_folder=spec --framework playwright --experimental --install_with=npm --force +rm -vf spec/playwright/e2e/rails_examples/advance_factory_bot.cy.js + echo '-- playwright run' cp -fv ../playwright.config.js spec/ cd spec npx playwright install-deps -npx playwright test spec/playwright/e2e/ +npx playwright install +npx playwright test spec/playwright/e2e echo '-- stop rails server' -kill -9 `cat tmp/pids/server.pid` || true +kill -9 `cat ../../server.pid` || true diff --git a/specs_e2e/rails_5_2/.gitignore b/specs_e2e/rails_5_2/.gitignore index d221e9a..d62f776 100644 --- a/specs_e2e/rails_5_2/.gitignore +++ b/specs_e2e/rails_5_2/.gitignore @@ -1,12 +1,16 @@ .bundle test/node_modules test/cypress.config.js +test/playwright.config.js test/package.json test/yarn.lock test/cypress/ +test/playwright/ +test/playwright-report/ config/initializers/cypress_on_rails.rb vendor/bundle db/*.sqlite3 db/schema.rb tmp/* log/* +specs_e2e/server.pid diff --git a/specs_e2e/rails_5_2/test.sh b/specs_e2e/rails_5_2/test.sh index 9956509..e91b55c 100755 --- a/specs_e2e/rails_5_2/test.sh +++ b/specs_e2e/rails_5_2/test.sh @@ -18,31 +18,40 @@ echo '-- migration' bundle exec ./bin/rails db:drop || true bundle exec ./bin/rails db:create db:migrate -echo '-- cypress and playwright install' -bundle exec ./bin/rails g cypress_on_rails:install --install_folder=test/e2e --cypress_folder=test/cypress --playwright_folder=test/playwright --install_cypress --install_playwright --install_with=npm --skip +echo '-- cypress install' +bundle exec ./bin/rails g cypress_on_rails:install --install_folder=test --framework cypress --install_with=npm --force rm -vf test/cypress/e2e/rails_examples/using_vcr.cy.js echo '-- start rails server' # make sure the server is not running -(kill -9 `cat tmp/pids/server.pid` || true ) +(kill -9 `cat ../server.pid` || true ) -bundle exec ./bin/rails server -p 5017 -e test & +bundle exec ./bin/rails server -p 5017 -e test -P ../server.pid & sleep 2 # give rails a chance to start up correctly echo '-- cypress run' cp -fv ../cypress.config.js test/ cd test +npx cypress install # if [ -z $CYPRESS_RECORD_KEY ] # then # npx cypress run # else - npx cypress run --record + npx cypress run # --record # fi +echo '-- playwright install' +cd .. +bundle exec ./bin/rails g cypress_on_rails:install --install_folder=test --framework playwright --install_with=npm --force +rm -vf test/playwright/e2e/rails_examples/using_vcr.cy.js + echo '-- playwright run' +cd test cp -fv ../../playwright.config.js . npx playwright install-deps -npx playwright test test/playwright/e2e/ +npx playwright install +npx playwright test test/playwright +# npx playwright show-report echo '-- stop rails server' -kill -9 `cat ../tmp/pids/server.pid` || true +kill -9 `cat ../../server.pid` || true