Skip to content

Commit

Permalink
fix: do not hard-code chrome for interactive e2e (#15837)
Browse files Browse the repository at this point in the history
* fix: do not hard-code chrome for interactive e2e

* chore: fix typo
  • Loading branch information
lmiller1990 authored Apr 8, 2021
1 parent 64cfa06 commit e8dbffe
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
27 changes: 23 additions & 4 deletions packages/server/lib/modes/interactive-ct.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
const serverCt = require('@packages/server-ct')
const { getBrowsers } = require('../browsers/utils')

const run = (options) => {
const { projectRoot } = options
const browsersForCtInteractive = ['chrome', 'chromium', 'edge', 'electron', 'firefox']

options.browser = options.browser || 'chrome'
const returnDefaultBrowser = (browsersByPriority, installedBrowsers) => {
const browserMap = installedBrowsers.reduce((acc, curr) => {
acc[curr.name] = true

return serverCt.start(projectRoot, options)
return acc
}, {})

for (const browser of browsersByPriority) {
if (browserMap[browser]) {
return browser
}
}
}

const run = async (options) => {
const installedBrowsers = await getBrowsers()

options.browser = options.browser || returnDefaultBrowser(browsersForCtInteractive, installedBrowsers)

return serverCt.start(options.projectRoot, options)
}

module.exports = {
run,
returnDefaultBrowser,
browsersForCtInteractive,
}
35 changes: 35 additions & 0 deletions packages/server/test/unit/modes/interactive-ct_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
require('../../spec_helper')

const { browsers } = require('@packages/launcher/lib/browsers')
const {
returnDefaultBrowser,
browsersForCtInteractive,
} = require(`${root}../lib/modes/interactive-ct`)

function filterBrowsers (list) {
return browsers.filter((browser) => list.includes(browser.name))
}

describe('returnDefaultBrowser', () => {
it('returns chrome by default is available', async () => {
const installedBrowsers = filterBrowsers(['electron', 'chromium', 'chrome'])
const actual = await returnDefaultBrowser(browsersForCtInteractive, installedBrowsers)

expect(actual).to.eq('chrome')
})

it('returns chromium if chrome is not installed', async () => {
const installedBrowsers = filterBrowsers(['electron', 'edge', 'chromium'])
const actual = await returnDefaultBrowser(browsersForCtInteractive, installedBrowsers)

expect(actual).to.eq('chromium')
})

it('returns undefined if no browser found', async () => {
// error message is handlded further down.
const installedBrowsers = filterBrowsers([])
const actual = await returnDefaultBrowser(browsersForCtInteractive, installedBrowsers)

expect(actual).to.eq(undefined)
})
})

4 comments on commit e8dbffe

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e8dbffe Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.2/circle-develop-e8dbffedd6f72752f0c7167fd8a6e95aad10f073/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e8dbffe Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 ia32 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.2/appveyor-develop-e8dbffedd6f72752f0c7167fd8a6e95aad10f073/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e8dbffe Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.2/appveyor-develop-e8dbffedd6f72752f0c7167fd8a6e95aad10f073/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on e8dbffe Apr 8, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/7.0.2/circle-develop-e8dbffedd6f72752f0c7167fd8a6e95aad10f073/cypress.tgz

Please sign in to comment.