diff --git a/cli/CHANGELOG.md b/cli/CHANGELOG.md index 257dcb96aa98..2085c9b154de 100644 --- a/cli/CHANGELOG.md +++ b/cli/CHANGELOG.md @@ -7,6 +7,7 @@ _Released 12/3/2024 (PENDING)_ - Removed support for Node.js 16 and Node.js 21. Addresses [#29930](https://github.com/cypress-io/cypress/issues/29930). - Prebuilt binaries for Linux are no longer compatible with Linux distributions based on glibc <2.28, for example: Ubuntu 14-18, RHEL 7, CentOS 7, Amazon Linux 2. Addresses [#29601](https://github.com/cypress-io/cypress/issues/29601). +- We removed yielding the second argument of `before:browser:launch` as an array of browser arguments. This behavior has been deprecated since Cypress 4.0.0. Addressed in [#30460](https://github.com/cypress-io/cypress/pull/30460). - The `cypress open-ct` and `cypress run-ct` CLI commands were removed. Please use `cypress open --component` or `cypress run --component` respectively instead. Addressed in [#30456](https://github.com/cypress-io/cypress/pull/30456) - The undocumented methods `Cypress.backend('firefox:force:gc')` and `Cypress.backend('log:memory:pressure')` were removed. Addresses [#30222](https://github.com/cypress-io/cypress/issues/30222). diff --git a/packages/errors/__snapshot-html__/DEPRECATED_BEFORE_BROWSER_LAUNCH_ARGS.html b/packages/errors/__snapshot-html__/DEPRECATED_BEFORE_BROWSER_LAUNCH_ARGS.html deleted file mode 100644 index 91c9b26e8662..000000000000 --- a/packages/errors/__snapshot-html__/DEPRECATED_BEFORE_BROWSER_LAUNCH_ARGS.html +++ /dev/null @@ -1,44 +0,0 @@ - - -
- - - - - - - - -Deprecation Warning: The before:browser:launch plugin event changed its signature in Cypress version 4.0.0
-
-The event switched from yielding the second argument as an array of browser arguments to an options object with an args property.
-
-We've detected that your code is still using the previous, deprecated interface signature.
-
-This code will not work in a future version of Cypress. Please see the upgrade guide: https://on.cypress.io/deprecated-before-browser-launch-args
-
\ No newline at end of file
diff --git a/packages/errors/src/errors.ts b/packages/errors/src/errors.ts
index 0a0725767946..81938ef15846 100644
--- a/packages/errors/src/errors.ts
+++ b/packages/errors/src/errors.ts
@@ -386,16 +386,6 @@ export const AllCypressErrors = {
https://on.cypress.io/auto-cancellation-mismatch`
},
- DEPRECATED_BEFORE_BROWSER_LAUNCH_ARGS: () => {
- return errTemplate`\
- Deprecation Warning: The ${fmt.highlight(`before:browser:launch`)} plugin event changed its signature in ${fmt.cypressVersion(`4.0.0`)}
-
- The event switched from yielding the second argument as an ${fmt.highlightSecondary(`array`)} of browser arguments to an options ${fmt.highlightSecondary(`object`)} with an ${fmt.highlightSecondary(`args`)} property.
-
- We've detected that your code is still using the previous, deprecated interface signature.
-
- This code will not work in a future version of Cypress. Please see the upgrade guide: https://on.cypress.io/deprecated-before-browser-launch-args`
- },
DUPLICATE_TASK_KEY: (arg1: string[]) => {
return errTemplate`\
Warning: Multiple attempts to register the following task(s):
diff --git a/packages/errors/test/unit/visualSnapshotErrors_spec.ts b/packages/errors/test/unit/visualSnapshotErrors_spec.ts
index 77b534bf7701..1b3a1db0fba6 100644
--- a/packages/errors/test/unit/visualSnapshotErrors_spec.ts
+++ b/packages/errors/test/unit/visualSnapshotErrors_spec.ts
@@ -570,11 +570,6 @@ describe('visual error templates', () => {
}],
}
},
- DEPRECATED_BEFORE_BROWSER_LAUNCH_ARGS: () => {
- return {
- default: [],
- }
- },
DUPLICATE_TASK_KEY: () => {
const tasks = ['foo', 'bar', 'baz']
diff --git a/packages/graphql/schemas/schema.graphql b/packages/graphql/schemas/schema.graphql
index 245a2e4a92cd..d5981ae96608 100644
--- a/packages/graphql/schemas/schema.graphql
+++ b/packages/graphql/schemas/schema.graphql
@@ -1181,7 +1181,6 @@ enum ErrorTypeEnum {
CONFIG_VALIDATION_MSG_ERROR
COULD_NOT_PARSE_ARGUMENTS
DEFAULT_SUPPORT_FILE_NOT_FOUND
- DEPRECATED_BEFORE_BROWSER_LAUNCH_ARGS
DEV_SERVER_CONFIG_FILE_NOT_FOUND
DUPLICATE_TASK_KEY
ERROR_READING_FILE
diff --git a/packages/server/lib/browsers/utils.ts b/packages/server/lib/browsers/utils.ts
index 9cc77cf98dc1..f71f669bfdb4 100644
--- a/packages/server/lib/browsers/utils.ts
+++ b/packages/server/lib/browsers/utils.ts
@@ -1,10 +1,9 @@
/* eslint-disable no-redeclare */
import Bluebird from 'bluebird'
import _ from 'lodash'
-import type { BrowserLaunchOpts, FoundBrowser } from '@packages/types'
+import type { FoundBrowser } from '@packages/types'
import * as errors from '../errors'
import * as plugins from '../plugins'
-import { getError } from '@packages/errors'
import * as launcher from '@packages/launcher'
import type { Automation } from '../automation'
import type { Browser } from './types'
@@ -179,36 +178,17 @@ async function executeAfterBrowserLaunch (browser: Browser, options: AfterBrowse
}
}
-function extendLaunchOptionsFromPlugins (launchOptions, pluginConfigResult, options: BrowserLaunchOpts) {
- // if we returned an array from the plugin
- // then we know the user is using the deprecated
- // interface and we need to warn them
- // TODO: remove this logic in >= v5.0.0
- if (pluginConfigResult[0]) {
- // eslint-disable-next-line no-console
- (options.onWarning || console.warn)(getError(
- 'DEPRECATED_BEFORE_BROWSER_LAUNCH_ARGS',
- ))
-
- _.extend(pluginConfigResult, {
- args: _.filter(pluginConfigResult, (_val, key) => {
- return _.isNumber(key)
- }),
- extensions: [],
- })
- } else {
- // either warn about the array or potentially error on invalid props, but not both
-
- // strip out all the known launch option properties from the resulting object
- const unexpectedProperties: string[] = _
- .chain(pluginConfigResult)
- .omit(KNOWN_LAUNCH_OPTION_PROPERTIES)
- .keys()
- .value()
-
- if (unexpectedProperties.length) {
- errors.throwErr('UNEXPECTED_BEFORE_BROWSER_LAUNCH_PROPERTIES', unexpectedProperties, KNOWN_LAUNCH_OPTION_PROPERTIES)
- }
+function extendLaunchOptionsFromPlugins (launchOptions, pluginConfigResult, options) {
+ // strip out all the known launch option properties from the resulting object
+ const unexpectedProperties: string[] = _
+ .chain(pluginConfigResult)
+ .omit(KNOWN_LAUNCH_OPTION_PROPERTIES)
+ .keys()
+ .value()
+
+ if (unexpectedProperties.length) {
+ // error on invalid props
+ errors.throwErr('UNEXPECTED_BEFORE_BROWSER_LAUNCH_PROPERTIES', unexpectedProperties, KNOWN_LAUNCH_OPTION_PROPERTIES)
}
_.forEach(launchOptions, (val, key) => {
diff --git a/packages/server/lib/plugins/child/browser_launch.js b/packages/server/lib/plugins/child/browser_launch.js
index 54b777d384e3..f5e0d449d53e 100644
--- a/packages/server/lib/plugins/child/browser_launch.js
+++ b/packages/server/lib/plugins/child/browser_launch.js
@@ -1,44 +1,7 @@
const util = require('../util')
-const ARRAY_METHODS = ['concat', 'push', 'unshift', 'slice', 'pop', 'shift', 'slice', 'splice', 'filter', 'map', 'forEach', 'reduce', 'reverse', 'splice', 'includes']
-
module.exports = {
wrapBefore (ipc, invoke, ids, args) {
- // TODO: remove in next breaking release
- // This will send a warning message when a deprecated API is used
- // define array-like functions on this object so we can warn about using deprecated array API
- // while still fulfilling desired behavior
- const [, launchOptions] = args
-
- let hasEmittedWarning = false
-
- ARRAY_METHODS.forEach((name) => {
- const boundFn = launchOptions.args[name].bind(launchOptions.args)
-
- launchOptions[name] = function () {
- if (hasEmittedWarning) return
-
- hasEmittedWarning = true
-
- const warning = require('@packages/errors').getError(
- 'DEPRECATED_BEFORE_BROWSER_LAUNCH_ARGS',
- )
-
- ipc.send('warning', util.serializeError(warning))
-
- // eslint-disable-next-line prefer-rest-params
- return boundFn.apply(this, arguments)
- }
- })
-
- Object.defineProperty(launchOptions, 'length', {
- get () {
- return this.args.length
- },
- })
-
- launchOptions[Symbol.iterator] = launchOptions.args[Symbol.iterator].bind(launchOptions.args)
-
util.wrapChildPromise(ipc, invoke, ids, args)
},
}
diff --git a/packages/server/test/unit/browsers/browsers_spec.js b/packages/server/test/unit/browsers/browsers_spec.js
index f9ea47278168..8e0d89766fd9 100644
--- a/packages/server/test/unit/browsers/browsers_spec.js
+++ b/packages/server/test/unit/browsers/browsers_spec.js
@@ -277,21 +277,6 @@ describe('lib/browsers/index', () => {
// this error is snapshotted in an e2e test, no need to do it here
expect(fn).to.throw({ type: 'UNEXPECTED_BEFORE_BROWSER_LAUNCH_PROPERTIES' })
})
-
- it('warns if array passed and changes it to args', () => {
- const onWarning = sinon.stub()
-
- const result = utils.extendLaunchOptionsFromPlugins({ args: [] }, ['foo'], { onWarning })
-
- expect(result).to.deep.eq({
- args: ['foo'],
- })
-
- // this error is snapshotted in e2e tests, no need to do it here
- expect(onWarning).to.be.calledOnce
-
- expect(onWarning).to.be.calledWithMatch({ type: 'DEPRECATED_BEFORE_BROWSER_LAUNCH_ARGS' })
- })
})
context('.getMajorVersion', () => {
diff --git a/packages/server/test/unit/browsers/chrome_spec.js b/packages/server/test/unit/browsers/chrome_spec.js
index b09f4de1b3bf..bac5bc17c723 100644
--- a/packages/server/test/unit/browsers/chrome_spec.js
+++ b/packages/server/test/unit/browsers/chrome_spec.js
@@ -224,30 +224,6 @@ describe('lib/browsers/chrome', () => {
})
})
- it('DEPRECATED: normalizes --load-extension if provided in plugin', function () {
- plugins.registerEvent('before:browser:launch', (browser, config) => {
- return Promise.resolve(['--foo=bar', '--load-extension=/foo/bar/baz.js'])
- })
-
- const pathToTheme = extension.getPathToTheme()
-
- const onWarning = sinon.stub()
-
- return chrome.open({ isHeaded: true }, 'http://', { onWarning, onError: () => {} }, this.automation)
- .then(() => {
- const args = launch.launch.firstCall.args[3]
-
- expect(args).to.deep.eq([
- '--foo=bar',
- `--load-extension=/foo/bar/baz.js,/path/to/ext,${pathToTheme}`,
- '--user-data-dir=/profile/dir',
- '--disk-cache-dir=/profile/dir/CypressCache',
- ])
-
- expect(onWarning).calledOnce
- })
- })
-
it('normalizes --load-extension if provided in plugin', function () {
plugins.registerEvent('before:browser:launch', (browser, config) => {
return Promise.resolve({
diff --git a/system-tests/__snapshots__/deprecated_spec.ts.js b/system-tests/__snapshots__/deprecated_spec.ts.js
index 4424fdfd9e53..d63ab478be94 100644
--- a/system-tests/__snapshots__/deprecated_spec.ts.js
+++ b/system-tests/__snapshots__/deprecated_spec.ts.js
@@ -30,166 +30,6 @@ launchOptions may only contain the properties:
https://on.cypress.io/browser-launch-api
-`
-
-exports['deprecated before:browser:launch args / push and no return - warns user exactly once'] = `
-
-====================================================================================================
-
- (Run Starting)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Cypress: 1.2.3 │
- │ Browser: FooBrowser 88 │
- │ Specs: 1 found (app.cy.js) │
- │ Searched: cypress/e2e/app.cy.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-────────────────────────────────────────────────────────────────────────────────────────────────────
-
- Running: app.cy.js (1 of 1)
-Deprecation Warning: The before:browser:launch plugin event changed its signature in Cypress version 4.0.0
-
-The event switched from yielding the second argument as an array of browser arguments to an options object with an args property.
-
-We've detected that your code is still using the previous, deprecated interface signature.
-
-This code will not work in a future version of Cypress. Please see the upgrade guide: https://on.cypress.io/deprecated-before-browser-launch-args
-
-
- ✓ asserts on browser args
-
- 1 passing
-
-
- (Results)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Tests: 1 │
- │ Passing: 1 │
- │ Failing: 0 │
- │ Pending: 0 │
- │ Skipped: 0 │
- │ Screenshots: 0 │
- │ Video: false │
- │ Duration: X seconds │
- │ Spec Ran: app.cy.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-====================================================================================================
-
- (Run Finished)
-
-
- Spec Tests Passing Failing Pending Skipped
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ ✔ app.cy.js XX:XX 1 1 - - - │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
- ✔ All specs passed! XX:XX 1 1 - - -
-
-
-`
-
-exports['deprecated before:browser:launch args / concat return returns once per spec - [electron]'] = `
-
-====================================================================================================
-
- (Run Starting)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Cypress: 1.2.3 │
- │ Browser: FooBrowser 88 │
- │ Specs: 2 found (app.cy.js, app_spec2.js) │
- │ Searched: cypress/e2e/app.cy.js, cypress/e2e/app_spec2.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-────────────────────────────────────────────────────────────────────────────────────────────────────
-
- Running: app.cy.js (1 of 2)
-Deprecation Warning: The before:browser:launch plugin event changed its signature in Cypress version 4.0.0
-
-The event switched from yielding the second argument as an array of browser arguments to an options object with an args property.
-
-We've detected that your code is still using the previous, deprecated interface signature.
-
-This code will not work in a future version of Cypress. Please see the upgrade guide: https://on.cypress.io/deprecated-before-browser-launch-args
-Warning: The following browser launch options were provided but are not supported by electron
-
- - args
-
-
- ✓ asserts on browser args
-
- 1 passing
-
-
- (Results)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Tests: 1 │
- │ Passing: 1 │
- │ Failing: 0 │
- │ Pending: 0 │
- │ Skipped: 0 │
- │ Screenshots: 0 │
- │ Video: false │
- │ Duration: X seconds │
- │ Spec Ran: app.cy.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-────────────────────────────────────────────────────────────────────────────────────────────────────
-
- Running: app_spec2.js (2 of 2)
-Deprecation Warning: The before:browser:launch plugin event changed its signature in Cypress version 4.0.0
-
-The event switched from yielding the second argument as an array of browser arguments to an options object with an args property.
-
-We've detected that your code is still using the previous, deprecated interface signature.
-
-This code will not work in a future version of Cypress. Please see the upgrade guide: https://on.cypress.io/deprecated-before-browser-launch-args
-Warning: The following browser launch options were provided but are not supported by electron
-
- - args
-
-
- ✓ 2 - asserts on browser args
-
- 1 passing
-
-
- (Results)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Tests: 1 │
- │ Passing: 1 │
- │ Failing: 0 │
- │ Pending: 0 │
- │ Skipped: 0 │
- │ Screenshots: 0 │
- │ Video: false │
- │ Duration: X seconds │
- │ Spec Ran: app_spec2.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-====================================================================================================
-
- (Run Finished)
-
-
- Spec Tests Passing Failing Pending Skipped
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ ✔ app.cy.js XX:XX 1 1 - - - │
- ├────────────────────────────────────────────────────────────────────────────────────────────────┤
- │ ✔ app_spec2.js XX:XX 1 1 - - - │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
- ✔ All specs passed! XX:XX 2 2 - - -
-
-
`
exports['deprecated before:browser:launch args / displays errors thrown and aborts the run'] = `
@@ -235,286 +75,3 @@ Promise rejected from plugins handler
Error: Promise rejected from plugins handler
[stack trace lines]
`
-
-exports['deprecated before:browser:launch args / using non-deprecated API - no warning - [electron]'] = `
-
-====================================================================================================
-
- (Run Starting)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Cypress: 1.2.3 │
- │ Browser: FooBrowser 88 │
- │ Specs: 1 found (app.cy.js) │
- │ Searched: cypress/e2e/app.cy.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-────────────────────────────────────────────────────────────────────────────────────────────────────
-
- Running: app.cy.js (1 of 1)
-Warning: The following browser launch options were provided but are not supported by electron
-
- - args
-
-
- ✓ asserts on browser args
-
- 1 passing
-
-
- (Results)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Tests: 1 │
- │ Passing: 1 │
- │ Failing: 0 │
- │ Pending: 0 │
- │ Skipped: 0 │
- │ Screenshots: 0 │
- │ Video: false │
- │ Duration: X seconds │
- │ Spec Ran: app.cy.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-====================================================================================================
-
- (Run Finished)
-
-
- Spec Tests Passing Failing Pending Skipped
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ ✔ app.cy.js XX:XX 1 1 - - - │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
- ✔ All specs passed! XX:XX 1 1 - - -
-
-
-`
-
-exports['deprecated before:browser:launch args / using non-deprecated API - no warning - [firefox,chromium]'] = `
-
-====================================================================================================
-
- (Run Starting)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Cypress: 1.2.3 │
- │ Browser: FooBrowser 88 │
- │ Specs: 1 found (app.cy.js) │
- │ Searched: cypress/e2e/app.cy.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-────────────────────────────────────────────────────────────────────────────────────────────────────
-
- Running: app.cy.js (1 of 1)
-
-
- ✓ asserts on browser args
-
- 1 passing
-
-
- (Results)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Tests: 1 │
- │ Passing: 1 │
- │ Failing: 0 │
- │ Pending: 0 │
- │ Skipped: 0 │
- │ Screenshots: 0 │
- │ Video: false │
- │ Duration: X seconds │
- │ Spec Ran: app.cy.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-====================================================================================================
-
- (Run Finished)
-
-
- Spec Tests Passing Failing Pending Skipped
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ ✔ app.cy.js XX:XX 1 1 - - - │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
- ✔ All specs passed! XX:XX 1 1 - - -
-
-
-`
-
-exports['deprecated before:browser:launch args / concat return returns once per test run - [firefox,chromium]'] = `
-
-====================================================================================================
-
- (Run Starting)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Cypress: 1.2.3 │
- │ Browser: FooBrowser 88 │
- │ Specs: 2 found (app.cy.js, app_spec2.js) │
- │ Searched: cypress/e2e/app.cy.js, cypress/e2e/app_spec2.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-────────────────────────────────────────────────────────────────────────────────────────────────────
-
- Running: app.cy.js (1 of 2)
-Deprecation Warning: The before:browser:launch plugin event changed its signature in Cypress version 4.0.0
-
-The event switched from yielding the second argument as an array of browser arguments to an options object with an args property.
-
-We've detected that your code is still using the previous, deprecated interface signature.
-
-This code will not work in a future version of Cypress. Please see the upgrade guide: https://on.cypress.io/deprecated-before-browser-launch-args
-
-
- ✓ asserts on browser args
-
- 1 passing
-
-
- (Results)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Tests: 1 │
- │ Passing: 1 │
- │ Failing: 0 │
- │ Pending: 0 │
- │ Skipped: 0 │
- │ Screenshots: 0 │
- │ Video: false │
- │ Duration: X seconds │
- │ Spec Ran: app.cy.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-────────────────────────────────────────────────────────────────────────────────────────────────────
-
- Running: app_spec2.js (2 of 2)
-
-
- ✓ 2 - asserts on browser args
-
- 1 passing
-
-
- (Results)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Tests: 1 │
- │ Passing: 1 │
- │ Failing: 0 │
- │ Pending: 0 │
- │ Skipped: 0 │
- │ Screenshots: 0 │
- │ Video: false │
- │ Duration: X seconds │
- │ Spec Ran: app_spec2.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-====================================================================================================
-
- (Run Finished)
-
-
- Spec Tests Passing Failing Pending Skipped
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ ✔ app.cy.js XX:XX 1 1 - - - │
- ├────────────────────────────────────────────────────────────────────────────────────────────────┤
- │ ✔ app_spec2.js XX:XX 1 1 - - - │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
- ✔ All specs passed! XX:XX 2 2 - - -
-
-
-`
-
-exports['deprecated before:browser:launch args / concat return returns once per test run - [firefox,chromium]'] = `
-
-====================================================================================================
-
- (Run Starting)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Cypress: 1.2.3 │
- │ Browser: FooBrowser 88 │
- │ Specs: 2 found (app.cy.js, app_spec2.js) │
- │ Searched: cypress/e2e/app.cy.js, cypress/e2e/app_spec2.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-────────────────────────────────────────────────────────────────────────────────────────────────────
-
- Running: app.cy.js (1 of 2)
-Deprecation Warning: The before:browser:launch plugin event changed its signature in Cypress version 4.0.0
-
-The event switched from yielding the second argument as an array of browser arguments to an options object with an args property.
-
-We've detected that your code is still using the previous, deprecated interface signature.
-
-This code will not work in a future version of Cypress. Please see the upgrade guide: https://on.cypress.io/deprecated-before-browser-launch-args
-
-
- ✓ asserts on browser args
-
- 1 passing
-
-
- (Results)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Tests: 1 │
- │ Passing: 1 │
- │ Failing: 0 │
- │ Pending: 0 │
- │ Skipped: 0 │
- │ Screenshots: 0 │
- │ Video: false │
- │ Duration: X seconds │
- │ Spec Ran: app.cy.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-────────────────────────────────────────────────────────────────────────────────────────────────────
-
- Running: app_spec2.js (2 of 2)
-
-
- ✓ 2 - asserts on browser args
-
- 1 passing
-
-
- (Results)
-
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ Tests: 1 │
- │ Passing: 1 │
- │ Failing: 0 │
- │ Pending: 0 │
- │ Skipped: 0 │
- │ Screenshots: 0 │
- │ Video: false │
- │ Duration: X seconds │
- │ Spec Ran: app_spec2.js │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
-
-
-====================================================================================================
-
- (Run Finished)
-
-
- Spec Tests Passing Failing Pending Skipped
- ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
- │ ✔ app.cy.js XX:XX 1 1 - - - │
- ├────────────────────────────────────────────────────────────────────────────────────────────────┤
- │ ✔ app_spec2.js XX:XX 1 1 - - - │
- └────────────────────────────────────────────────────────────────────────────────────────────────┘
- ✔ All specs passed! XX:XX 2 2 - - -
-
-
-`
diff --git a/system-tests/projects/plugin-browser/cypress.config.js b/system-tests/projects/plugin-browser/cypress.config.js
index f9360cdc0e99..efba4d966cd8 100644
--- a/system-tests/projects/plugin-browser/cypress.config.js
+++ b/system-tests/projects/plugin-browser/cypress.config.js
@@ -2,22 +2,25 @@ module.exports = {
'e2e': {
'supportFile': false,
setupNodeEvents (on, config) {
- on('before:browser:launch', (browser) => {
+ on('before:browser:launch', (browser, launchOptions) => {
const { name } = browser
- switch (name) {
- case 'chrome':
- return [name, 'foo', 'bar', 'baz']
- case 'electron':
- return {
- preferences: {
- browser: 'electron',
- foo: 'bar',
- },
- }
- default:
- throw new Error(`unrecognized browser name: '${name}' for before:browser:launch`)
+ if ((name) === 'chrome') {
+ launchOptions.args = [name, 'foo', 'bar', 'baz']
+
+ return launchOptions
}
+
+ if ((name) === 'electron') {
+ launchOptions.preferences = {
+ browser: 'electron',
+ foo: 'bar',
+ }
+
+ return launchOptions
+ }
+
+ throw new Error(`unrecognized browser name: '${name}' for before:browser:launch`)
})
return config
diff --git a/system-tests/test/deprecated_spec.ts b/system-tests/test/deprecated_spec.ts
index 94b7549e4af2..38ed7f855d16 100644
--- a/system-tests/test/deprecated_spec.ts
+++ b/system-tests/test/deprecated_spec.ts
@@ -2,18 +2,6 @@ import systemTests from '../lib/system-tests'
const beforeBrowserLaunchProject = 'plugin-before-browser-launch-deprecation'
-const includesString = (s: string) => {
- return (stdout: string) => {
- expect(stdout).to.include(s)
- }
-}
-
-const excludesString = (s: string) => {
- return (stdout: string) => {
- expect(stdout).to.not.include(s)
- }
-}
-
describe('deprecated before:browser:launch args', () => {
systemTests.setup()
@@ -30,85 +18,6 @@ describe('deprecated before:browser:launch args', () => {
snapshot: true,
})
- systemTests.it('push and no return - warns user exactly once', {
- browser: '!webkit', // TODO(webkit): fix+unskip (add executeBeforeBrowserLaunch to WebKit)
- config: {
- env: {
- BEFORE_BROWSER_LAUNCH_HANDLER: 'return-undefined-mutate-array',
- },
- },
- project: beforeBrowserLaunchProject,
- spec: 'app.cy.js',
- snapshot: true,
- onStdout: includesString('Deprecation Warning:'),
- })
-
- systemTests.it('using non-deprecated API - no warning', {
- // TODO: implement webPreferences.additionalArgs here
- // once we decide if/what we're going to make the implementation
- // SUGGESTION: add this to Cypress.browser.args which will capture
- // whatever args we use to launch the browser
- browser: '!webkit', // throws in WebKit since it rejects unsupported arguments
- config: {
- env: {
- BEFORE_BROWSER_LAUNCH_HANDLER: 'return-launch-options-mutate-only-args-property',
- },
- },
- project: beforeBrowserLaunchProject,
- spec: 'app.cy.js',
- snapshot: true,
- onRun: (exec, browser) => {
- if (browser === 'electron') {
- return exec({ originalTitle: `deprecated before:browser:launch args / using non-deprecated API - no warning - [electron]` })
- }
-
- return exec({ originalTitle: `deprecated before:browser:launch args / using non-deprecated API - no warning - [firefox,chromium]` })
- },
- onStdout: excludesString('Deprecation Warning:'),
- })
-
- systemTests.it('concat return returns once', {
- // TODO: implement webPreferences.additionalArgs here
- // once we decide if/what we're going to make the implementation
- // SUGGESTION: add this to Cypress.browser.args which will capture
- // whatever args we use to launch the browser
- browser: '!webkit', // throws in WebKit since it rejects unsupported arguments
- config: {
- env: {
- BEFORE_BROWSER_LAUNCH_HANDLER: 'return-array-mutation',
- },
- },
- project: beforeBrowserLaunchProject,
- spec: 'app.cy.js,app_spec2.js',
- snapshot: true,
- onRun: (exec, browser) => {
- if (browser === 'electron') {
- return exec({ originalTitle: `deprecated before:browser:launch args / concat return returns once per spec - [electron]` })
- }
-
- return exec({ originalTitle: `deprecated before:browser:launch args / concat return returns once per test run - [firefox,chromium]` })
- },
- onStdout: includesString('Deprecation Warning:'),
- })
-
- // TODO: fix/remove this test, it should be warning but is not
- // https://github.com/cypress-io/cypress/issues/20436
- systemTests.it.skip('no mutate return', {
- // TODO: implement webPreferences.additionalArgs here
- // once we decide if/what we're going to make the implementation
- // SUGGESTION: add this to Cypress.browser.args which will capture
- // whatever args we use to launch the browser
- config: {
- env: {
- BEFORE_BROWSER_LAUNCH_HANDLER: 'return-new-array-without-mutation',
- },
- },
- project: beforeBrowserLaunchProject,
- spec: 'app.cy.js',
- snapshot: true,
- onStdout: includesString('Deprecation Warning:'),
- })
-
// TODO: these errors could be greatly improved by the code frame
// improvements - because we "wrap" the user error with our own
// error which reads strangely - the message + stack are both