79444173

Date: 2025-02-17 00:24:35
Score: 0.5
Natty:
Report link

For the question How do I get the version of the currently installed browser.

The answer is here Customize available browsers (second block).

Essentially, the config reaches out to the OS using execa() to find the current version of the specified browser.

You seem to have multiple browser types, so some adjustment to this code will be needed

const { defineConfig } = require('cypress')
const execa = require('execa')

const findBrowser = () => {
  // the path is hard-coded for simplicity
  const browserPath =
    '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser'

  return execa(browserPath, ['--version']).then((result) => {
    // STDOUT will be like "Brave Browser 77.0.69.135"
    const [, version] = /Brave Browser (\d+\.\d+\.\d+\.\d+)/.exec(result.stdout)
    const majorVersion = parseInt(version.split('.')[0])

    return {
      name: 'Brave',
      channel: 'stable',
      family: 'chromium',
      displayName: 'Brave',
      version,
      path: browserPath,
      majorVersion,
    }
  })
}

module.exports = defineConfig({
  // setupNodeEvents can be defined in either
  // the e2e or component configuration
  e2e: {
    setupNodeEvents(on, config) {
      return findBrowser().then((browser) => {
        return {
          browsers: config.browsers.concat(browser),
        }
      })
    },
  },
})

For the question How can I make the cypress.config just download the latest stable.

Reasons:
  • Blacklisted phrase (0.5): How can I
  • Blacklisted phrase (1): How do I
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Spara