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

Remove --browser canary backwards-compatibility #6333

Merged
merged 4 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/server/__snapshots__/browsers_spec.coffee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
exports['lib/browsers/index .ensureAndGetByNameOrPath throws when no browser can be found 1'] = `
Can't run because you've entered an invalid browser name.

Browser: 'browserNotGonnaBeFound' was not found on your system.

Available browsers found are: chrome, electron
`

exports['lib/browsers/index .ensureAndGetByNameOrPath throws a special error when canary is passed 1'] = `
Can't run because you've entered an invalid browser name.

Browser: 'canary' was not found on your system.

Available browsers found are: chrome, chrome:canary, firefox

Note: In Cypress 4.0, Canary must be launched as \`chrome:canary\`, not \`canary\`.

See https://on.cypress.io/migration-guide for more information on breaking changes in 4.0.
`
7 changes: 1 addition & 6 deletions packages/server/lib/browsers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const kill = function (unbind) {
instance.removeAllListeners()
}

instance.once('exit', function (...args) {
instance.once('exit', (...args) => {
debug('browser process killed')

return resolve.apply(null, args)
Expand Down Expand Up @@ -61,11 +61,6 @@ const isValidPathToBrowser = (str) => {
}

const parseBrowserOption = (opt) => {
// for backwards compatibility pre-4.x
if (opt === 'canary') {
opt = 'chrome:canary'
}

// it's a name or a path
if (!_.isString(opt) || !opt.includes(':')) {
return {
Expand Down
11 changes: 10 additions & 1 deletion packages/server/lib/errors.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,22 @@ getMsgByType = (type, arg1 = {}, arg2, arg3) ->
#{arg1}
"""
when "BROWSER_NOT_FOUND_BY_NAME"
"""
str = """
Can't run because you've entered an invalid browser name.

Browser: '#{arg1}' was not found on your system.

Available browsers found are: #{arg2}
"""

if arg1 is 'canary'
str += """
\n\nNote: In Cypress 4.0, Canary must be launched as `chrome:canary`, not `canary`.

See https://on.cypress.io/migration-guide for more information on breaking changes in 4.0.
"""

return str
when "BROWSER_NOT_FOUND_BY_PATH"
msg = """
We could not identify a known browser at the path you provided: `#{arg1}`
Expand Down
23 changes: 17 additions & 6 deletions packages/server/test/unit/browsers/browsers_spec.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require("../../spec_helper")

_ = require("lodash")
flotwig marked this conversation as resolved.
Show resolved Hide resolved
Promise = require("bluebird")
Windows = require("#{root}../lib/gui/windows")
browsers = require("#{root}../lib/browsers")
Expand Down Expand Up @@ -36,12 +37,22 @@ describe "lib/browsers/index", ->
expect(browser).to.deep.eq({ name: "foo", channel: "stable" })

it "throws when no browser can be found", ->
browsers.ensureAndGetByNameOrPath("browserNotGonnaBeFound")
.then ->
throw new Error("should have failed")
.catch (err) ->
expect(err.type).to.eq("BROWSER_NOT_FOUND_BY_NAME")
expect(err.message).to.contain("'browserNotGonnaBeFound' was not found on your system")
expect(browsers.ensureAndGetByNameOrPath("browserNotGonnaBeFound"))
.to.be.rejectedWith({ type: 'BROWSER_NOT_FOUND_BY_NAME' })
.then (err) ->
snapshot(err.message)

it "throws a special error when canary is passed", ->
sinon.stub(utils, "getBrowsers").resolves([
{ name: "chrome", channel: "stable" }
{ name: "chrome", channel: "canary" }
{ name: "firefox", channel: "stable" }
])

expect(browsers.ensureAndGetByNameOrPath("canary"))
.to.be.rejectedWith({ type: 'BROWSER_NOT_FOUND_BY_NAME' })
.then (err) ->
snapshot(err.message)

context ".open", ->
it "throws an error if browser family doesn't exist", ->
Expand Down