Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: Add browser support check and update supported browser messages #29066

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions packages/errors/__snapshot-html__/BROWSER_NOT_SUPPORTED.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions packages/errors/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,42 @@ export const AllCypressErrors = {

${fmt.listItems(options)}`
},
BROWSER_NOT_FOUND_BY_NAME: (browser: string, foundBrowsersStr: string[]) => {
BROWSER_NOT_SUPPORTED: (browser: string, foundBrowsersStr: string[]) => {
let canarySuffix: PartialErr | null = null

if (browser === 'canary') {
canarySuffix = errPartial`\
${fmt.off('\n\n')}
Note: In ${fmt.cypressVersion(`4.0.0`)}, Canary must be launched as ${fmt.highlightSecondary(`chrome:canary`)}, not ${fmt.highlightSecondary(`canary`)}.
Note: Since ${fmt.cypressVersion(`4.0.0`)}, Canary must be launched as ${fmt.highlightSecondary(`chrome:canary`)}, not ${fmt.highlightSecondary(`canary`)}.

See https://on.cypress.io/migration-guide for more information on breaking changes in 4.0.0.`
}

return errTemplate`\
Can't run because you've entered an invalid browser name.
Can't run because you've entered a browser that is not supported by Cypress.

Browser: ${fmt.highlight(browser)} was not found on your system or is not supported by Cypress.
Browser: ${fmt.highlight(browser)} is not supported by Cypress.

Cypress supports the following browsers:
${fmt.listItems(['electron', 'chrome', 'chromium', 'chrome:canary', 'edge', 'firefox'])}
${fmt.listItems(['electron', 'chrome', 'chromium', 'chrome:canary', 'edge', 'firefox', 'webkit'])}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we note here that webkit support is still experimental?

Copy link
Author

@0v00 0v00 Apr 3, 2024

Choose a reason for hiding this comment

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

@cacieprins @jennifer-shehane sorry for the delay, will jump back on the pr this week


You can also use a custom browser: https://on.cypress.io/customize-browsers

Available browsers found on your system are:
${fmt.listItems(foundBrowsersStr)}${canarySuffix}`
},
BROWSER_NOT_FOUND_BY_NAME: (browser: string, foundBrowsersStr: string[]) => {
return errTemplate`\
Browser: ${fmt.highlight(browser)} was not found on your system.

Cypress supports the following browsers:
${fmt.listItems(['electron', 'chrome', 'chromium', 'chrome:canary', 'edge', 'firefox', 'webkit'])}

You can also use a custom browser: https://on.cypress.io/customize-browsers

Available browsers found on your system are:
${fmt.listItems(foundBrowsersStr)}`
},
BROWSER_NOT_FOUND_BY_PATH: (arg1: string, arg2: string) => {
return errTemplate`\
We could not identify a known browser at the path you provided: ${fmt.path(arg1)}
Expand Down
7 changes: 6 additions & 1 deletion packages/errors/test/unit/visualSnapshotErrors_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,17 @@ describe('visual error templates', () => {
default: ['firefox'],
}
},
BROWSER_NOT_FOUND_BY_NAME: () => {
BROWSER_NOT_SUPPORTED: () => {
return {
default: ['invalid-browser', browsers.formatBrowsersToOptions(knownBrowsers)],
canary: ['canary', browsers.formatBrowsersToOptions(knownBrowsers)],
}
},
BROWSER_NOT_FOUND_BY_NAME: () => {
return {
default: ['invalid-browser', browsers.formatBrowsersToOptions(knownBrowsers)],
}
},
BROWSER_NOT_FOUND_BY_PATH: () => {
const err = makeErr()

Expand Down