Sha256: 46f4876012e81b1373a4178db97ea4876fe0ea8642b64eaf17aa4a52638c9ae9

Contents?: true

Size: 936 Bytes

Versions: 2

Compression:

Stored size: 936 Bytes

Contents

module CypressRails
  class Init
    DEFAULT_CONFIG = <<~JS
      const { defineConfig } = require('cypress')

      module.exports = defineConfig({
        // setupNodeEvents can be defined in either
        // the e2e or component configuration
        e2e: {
          setupNodeEvents(on, config) {
            on('before:browser:launch', (browser = {}, launchOptions) => {
              /* ... */
            })
          },
        },
        screenshotsFolder: "tmp/cypress_screenshots",
        videosFolder: "tmp/cypress_videos",
        trashAssetsBeforeRuns: false
      })
    JS

    def call(dir = Dir.pwd)
      config_path = File.join(dir, "cypress.config.js")
      if !File.exist?(config_path)
        File.write(config_path, DEFAULT_CONFIG)
        puts "Cypress config initialized in `#{config_path}'"
      else
        warn "Cypress config already exists in `#{config_path}'. Skipping."
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cypress-rails-0.6.1 lib/cypress-rails/init.rb
cypress-rails-0.6.0 lib/cypress-rails/init.rb