-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: do not hard-code chrome for interactive e2e (#15837)
* fix: do not hard-code chrome for interactive e2e * chore: fix typo
- Loading branch information
1 parent
64cfa06
commit e8dbffe
Showing
2 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) |
e8dbffe
There was a problem hiding this comment.
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:
e8dbffe
There was a problem hiding this comment.
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:
e8dbffe
There was a problem hiding this comment.
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:
e8dbffe
There was a problem hiding this comment.
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: