diff --git a/.cypress.ci.env.json b/.cypress.ci.env.json new file mode 100644 index 000000000000..1a79ceb11634 --- /dev/null +++ b/.cypress.ci.env.json @@ -0,0 +1,3 @@ +{ + "disable_screenshots": "true" +} diff --git a/.cypress.dev.env.json b/.cypress.dev.env.json new file mode 100644 index 000000000000..18c5362392c4 --- /dev/null +++ b/.cypress.dev.env.json @@ -0,0 +1,3 @@ +{ + "disable_screenshots": "false" +} diff --git a/.gitignore b/.gitignore index bf1f7099e4e1..6c5c1acb42af 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ config/webpack/paths.json *.sw[po] cypress/screenshots cypress/videos +cypress.env.json diff --git a/cypress/support/index.js b/cypress/support/index.js index 94ef7ce3f798..f9d539cd7c84 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -19,8 +19,6 @@ import './commands' // Alternatively you can use CommonJS syntax: // require('./commands') -const { env } = require('process') - -if (env.TRAVIS || env.CI) { - Cypress.Screenshot.defaults({screenshotOnRunFailure: false}) -} +Cypress.Screenshot.defaults({ + screenshotOnRunFailure: !(Cypress.env('disable_screenshots') == 'true') +}) diff --git a/lib/tasks/manageiq/cypress.rake b/lib/tasks/manageiq/cypress.rake index 32c228eee3cc..e639be1afa6a 100644 --- a/lib/tasks/manageiq/cypress.rake +++ b/lib/tasks/manageiq/cypress.rake @@ -1,3 +1,5 @@ +CYPRESS_ENV_FILE = File.expand_path(File.join("..", "..", "..", "cypress.env.json"), __dir__) unless defined?(CYPRESS_ENV_FILE) + namespace :cypress do desc "Run cypress tests" task :ui => 'ui:run' @@ -25,11 +27,21 @@ namespace :cypress do Rake::Task["#{app_prefix}integration:stop_server"].invoke end - task :setup do |rake_task| + task :setup => CYPRESS_ENV_FILE do |rake_task| app_prefix = rake_task.name.chomp('cypress:ui:setup') Rake::Task["#{app_prefix}integration:start_server"].invoke end + file CYPRESS_ENV_FILE do |cypress_env_json_file| + unless File.exist?(CYPRESS_ENV_FILE) + cypress_dir = File.dirname(CYPRESS_ENV_FILE) + cypress_env_example = ".cypress.dev.env.json" + cypress_env_example = ".cypress.ci.env.json" if ENV['CI'] || ENV['TRAVIS'] + + cp File.join(cypress_dir, cypress_env_example), cypress_env_json_file.name + end + end + desc "Run cypress tests in 'development' mode" task :dev => 'dev:run'