Skip to content

Commit c2f91f6

Browse files
authored
Merge pull request #16831 from cypress-io/8.0-release
BREAKING CHANGE: 8.0 release
2 parents ae0c520 + 62f492b commit c2f91f6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+447
-1051
lines changed

cli/__snapshots__/cli_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ exports['shows help for run --foo 1'] = `
6969
-e, --env <env> sets environment variables. separate multiple values with a comma. overrides any value in cypress.json or cypress.env.json
7070
--group <name> a named group for recorded runs in the Cypress Dashboard
7171
-k, --key <record-key> your secret Record Key. you can omit this if you set a CYPRESS_RECORD_KEY environment variable.
72-
--headed displays the browser instead of running headlessly (defaults to true for Firefox and Chromium-family browsers)
73-
--headless hide the browser instead of running headed (defaults to true for Electron)
72+
--headed displays the browser instead of running headlessly
73+
--headless hide the browser instead of running headed (default for cypress run)
7474
--no-exit keep the browser open after tests finish
7575
--parallel enables concurrent runs and automatic load balancing of specs across multiple machines or processes
7676
-p, --port <port> runs Cypress on a specific port. overrides any value in cypress.json.

cli/lib/cli.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ const descriptions = {
115115
forceInstall: 'force install the Cypress binary',
116116
global: 'force Cypress into global mode as if its globally installed',
117117
group: 'a named group for recorded runs in the Cypress Dashboard',
118-
headed: 'displays the browser instead of running headlessly (defaults to true for Firefox and Chromium-family browsers)',
119-
headless: 'hide the browser instead of running headed (defaults to true for Electron)',
118+
headed: 'displays the browser instead of running headlessly',
119+
headless: 'hide the browser instead of running headed (default for cypress run)',
120120
key: 'your secret Record Key. you can omit this if you set a CYPRESS_RECORD_KEY environment variable.',
121121
parallel: 'enables concurrent runs and automatic load balancing of specs across multiple machines or processes',
122122
port: 'runs Cypress on a specific port. overrides any value in cypress.json.',

cli/types/cypress-npm-api.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ declare namespace CypressCommandLine {
138138
/**
139139
* Specify configuration
140140
*/
141-
config: Partial<Cypress.ResolvedConfigOptions>
141+
config: Cypress.ConfigOptions
142142
/**
143143
* Path to the config file to be used.
144144
*

cli/types/cypress.d.ts

Lines changed: 56 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ declare namespace Cypress {
6464
path: string
6565
isHeaded: boolean
6666
isHeadless: boolean
67+
/**
68+
* Informational text to accompany this browser. Shown in desktop-gui.
69+
*/
70+
info?: string
71+
/**
72+
* Warning text to accompany this browser. Shown in desktop-gui.
73+
*/
74+
warning?: string
75+
/**
76+
* The minimum majorVersion of this browser supported by Cypress.
77+
*/
78+
minSupportedVersion?: number
79+
/**
80+
* If `true`, this browser is too old to be supported by Cypress.
81+
*/
82+
unsupportedVersion?: boolean
6783
}
6884

6985
interface LocalStorage {
@@ -341,15 +357,6 @@ declare namespace Cypress {
341357
*/
342358
env(object: ObjectLike): void
343359

344-
/**
345-
* Firefox only: Get the current number of tests that will run between forced garbage collections.
346-
*
347-
* Returns undefined if not in Firefox, returns a null or 0 if forced GC is disabled.
348-
*
349-
* @see https://on.cypress.io/firefox-gc-issue
350-
*/
351-
getFirefoxGcInterval(): number | null | undefined
352-
353360
/**
354361
* @returns the number of test retries currently enabled for the run
355362
*/
@@ -1833,6 +1840,12 @@ declare namespace Cypress {
18331840
* @see https://on.cypress.io/then
18341841
*/
18351842
then<S>(options: Partial<Timeoutable>, fn: (this: ObjectLike, currentSubject: Subject) => PromiseLike<S>): Chainable<S>
1843+
/**
1844+
* Enables you to work with the subject yielded from the previous command / promise.
1845+
*
1846+
* @see https://on.cypress.io/then
1847+
*/
1848+
then<S extends string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
18361849
/**
18371850
* Enables you to work with the subject yielded from the previous command / promise.
18381851
*
@@ -1850,7 +1863,7 @@ declare namespace Cypress {
18501863
*
18511864
* @see https://on.cypress.io/then
18521865
*/
1853-
then<S extends object | any[] | string | number | boolean>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
1866+
then<S extends any[] | object>(fn: (this: ObjectLike, currentSubject: Subject) => S): Chainable<S>
18541867
/**
18551868
* Enables you to work with the subject yielded from the previous command / promise.
18561869
*
@@ -2640,13 +2653,6 @@ declare namespace Cypress {
26402653
* @default 'top'
26412654
*/
26422655
scrollBehavior: scrollBehaviorOptions
2643-
/**
2644-
* Firefox version 79 and below only: The number of tests that will run between forced garbage collections.
2645-
* If a number is supplied, it will apply to `run` mode and `open` mode.
2646-
* Set the interval to `null` or 0 to disable forced garbage collections.
2647-
* @default { runMode: 1, openMode: null }
2648-
*/
2649-
firefoxGcInterval: Nullable<number | { runMode: Nullable<number>, openMode: Nullable<number> }>
26502656
/**
26512657
* Allows listening to the `before:run`, `after:run`, `before:spec`, and `after:spec` events in the plugins file during interactive mode.
26522658
* @default false
@@ -2678,17 +2684,46 @@ declare namespace Cypress {
26782684
*/
26792685
includeShadowDom: boolean
26802686

2687+
/**
2688+
* The list of hosts to be blocked
2689+
*/
2690+
blockHosts: null | string | string[]
2691+
/**
2692+
* Path to folder containing component test files.
2693+
*/
2694+
componentFolder: false | string
2695+
/**
2696+
* A unique ID for the project used for recording
2697+
*/
2698+
projectId: null | string
2699+
/**
2700+
* Path to the support folder.
2701+
*/
2702+
supportFolder: string
2703+
/**
2704+
* Glob pattern to determine what test files to load.
2705+
*/
2706+
testFiles: string | string[]
2707+
/**
2708+
* The user agent the browser sends in all request headers.
2709+
*/
2710+
userAgent: null | string
2711+
/**
2712+
* Polyfills `window.fetch` to enable Network spying and stubbing
2713+
*/
2714+
experimentalFetchPolyfill: boolean
2715+
26812716
/**
26822717
* Override default config options for Component Testing runner.
26832718
* @default {}
26842719
*/
2685-
component: ResolvedConfigOptions
2720+
component: Omit<ResolvedConfigOptions, 'e2e' | 'component'>
26862721

26872722
/**
26882723
* Override default config options for E2E Testing runner.
26892724
* @default {}
26902725
*/
2691-
e2e: ResolvedConfigOptions
2726+
e2e: Omit<ResolvedConfigOptions, 'e2e' | 'component'>
26922727
}
26932728

26942729
/**
@@ -2701,10 +2736,6 @@ declare namespace Cypress {
27012736
* @see https://nodejs.org/api/os.html#os_os_arch
27022737
*/
27032738
arch: string
2704-
/**
2705-
* The list of hosts to be blocked
2706-
*/
2707-
blockHosts: null | string | string[]
27082739
/**
27092740
* The browser Cypress is running on.
27102741
*/
@@ -2713,10 +2744,6 @@ declare namespace Cypress {
27132744
* Available browsers found on your system.
27142745
*/
27152746
browsers: Browser[]
2716-
/**
2717-
* Path to folder containing component test files.
2718-
*/
2719-
componentFolder: string
27202747
/**
27212748
* Hosts mappings to IP addresses.
27222749
*/
@@ -2736,22 +2763,6 @@ declare namespace Cypress {
27362763
* The platform Cypress is running on.
27372764
*/
27382765
platform: 'linux' | 'darwin' | 'win32'
2739-
/**
2740-
* A unique ID for the project used for recording
2741-
*/
2742-
projectId: null | string
2743-
/**
2744-
* Path to the support folder.
2745-
*/
2746-
supportFolder: string
2747-
/**
2748-
* Glob pattern to determine what test files to load.
2749-
*/
2750-
testFiles: string
2751-
/**
2752-
* The user agent the browser sends in all request headers.
2753-
*/
2754-
userAgent: null | string
27552766
/**
27562767
* The Cypress version being used.
27572768
*/
@@ -2798,7 +2809,8 @@ declare namespace Cypress {
27982809
/**
27992810
* All configuration items are optional.
28002811
*/
2801-
type ConfigOptions = Partial<ResolvedConfigOptions>
2812+
type CoreConfigOptions = Partial<Omit<ResolvedConfigOptions, 'e2e' | 'component'>>
2813+
type ConfigOptions = CoreConfigOptions & {e2e?: CoreConfigOptions, component?: CoreConfigOptions }
28022814

28032815
interface PluginConfigOptions extends ResolvedConfigOptions {
28042816
/**

cli/types/tests/cypress-tests.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,15 @@ describe('then', () => {
257257
$p // $ExpectType JQuery<HTMLParagraphElement>
258258
})
259259
})
260+
261+
// https://github.com/cypress-io/cypress/issues/16669
262+
it('any as default', () => {
263+
cy.get('body')
264+
.then(() => ({} as any))
265+
.then(v => {
266+
v // $ExpectType any
267+
})
268+
})
260269
})
261270

262271
cy.wait(['@foo', '@bar'])

packages/desktop-gui/cypress/fixtures/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
"channel": "stable",
8484
"version": "69.0.1",
8585
"path": "/Applications/Firefox/Contents/MacOS/Firefox",
86-
"majorVersion": "69"
86+
"majorVersion": "69",
87+
"unsupportedVersion": true
8788
},
8889
{
8990
"name": "firefox",

packages/desktop-gui/cypress/integration/project_nav_spec.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,20 @@ describe('Project Nav', function () {
204204
})
205205
})
206206

207+
it('has unsupportedVersions styled and unselectable', function () {
208+
cy.get('.browsers-list .dropdown-chosen').click()
209+
210+
cy.get('.browsers-list').find('.dropdown-menu')
211+
.find('li').should('have.length', this.config.browsers.length - 1)
212+
.contains('span', 'Firefox 69')
213+
.should('have.class', 'unsupported-version')
214+
.click()
215+
216+
cy.get('.browsers-list .dropdown-menu').should('be.visible')
217+
218+
cy.get('.browsers-list .dropdown-chosen').contains('Chromium')
219+
})
220+
207221
it('saves chosen browser in local storage', () => {
208222
expect(localStorage.getItem('chosenBrowser')).to.eq(JSON.stringify({ name: 'chromium', channel: 'stable' }))
209223
})
@@ -255,7 +269,7 @@ describe('Project Nav', function () {
255269
const browserArg = this.ipc.launchBrowser.getCall(0).args[0].browser
256270

257271
expect(browserArg).to.have.keys([
258-
'family', 'name', 'path', 'profilePath', 'version', 'majorVersion', 'displayName', 'info', 'isChosen', 'custom', 'warning', 'channel',
272+
'family', 'name', 'path', 'profilePath', 'version', 'majorVersion', 'displayName', 'info', 'isChosen', 'custom', 'warning', 'channel', 'unsupportedVersion',
259273
])
260274

261275
expect(browserArg.path).to.include('/')
@@ -364,6 +378,22 @@ describe('Project Nav', function () {
364378
})
365379
})
366380

381+
describe('when browser saved in local storage has an unsupported version', function () {
382+
beforeEach(function () {
383+
localStorage.setItem('chosenBrowser', JSON.stringify({ name: 'firefox', channel: 'stable' }))
384+
385+
// sanity check: saved browser should be found in the config
386+
expect(this.config.browsers.find((b) => b.name === 'firefox' && b.channel === 'stable' && b.unsupportedVersion)).to.exist
387+
388+
this.openProject.resolve(this.config)
389+
})
390+
391+
it('defaults to first browser', () => {
392+
cy.get('.browsers-list .dropdown-chosen')
393+
.should('contain', 'Chrome')
394+
})
395+
})
396+
367397
describe('only one browser available', function () {
368398
beforeEach(function () {
369399
this.config.browsers = [{

packages/desktop-gui/src/app/nav.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,13 @@
236236
li {
237237
padding: 9px 15px;
238238
white-space: nowrap;
239+
240+
.unsupported-version {
241+
color: #888;
242+
img {
243+
filter: opacity(0.5);
244+
}
245+
}
239246
}
240247

241248
.dropdown-chosen {

packages/desktop-gui/src/lib/browser-model.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default class Browser {
1212
@observable info
1313
@observable custom
1414
@observable warning
15+
@observable unsupportedVersion
1516
@observable isChosen = false
1617

1718
constructor (browser) {
@@ -26,5 +27,6 @@ export default class Browser {
2627
this.info = browser.info
2728
this.custom = browser.custom
2829
this.warning = browser.warning
30+
this.unsupportedVersion = browser.unsupportedVersion
2931
}
3032
}

packages/desktop-gui/src/project-nav/browsers.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { Component } from 'react'
22
import { observer } from 'mobx-react'
3+
import cs from 'classnames'
34
import Tooltip from '@cypress/react-tooltip'
45
import { BrowserIcon, Dropdown } from '@packages/ui-components'
56

@@ -49,6 +50,8 @@ export default class Browsers extends Component {
4950
}
5051

5152
_onSelect = (browser) => {
53+
if (browser.unsupportedVersion) return true
54+
5255
this.props.project.setChosenBrowser(browser)
5356
}
5457

@@ -69,14 +72,14 @@ export default class Browsers extends Component {
6972
}
7073

7174
return (
72-
<>
75+
<span className={cs({ 'unsupported-version': browser.unsupportedVersion })}>
7376
{icon}{' '}
7477
{prefixText}{' '}
7578
{browser.displayName}{' '}
7679
{browser.majorVersion}
7780
{this._info(browser)}
7881
{this._warn(browser)}
79-
</>
82+
</span>
8083
)
8184
}
8285

packages/desktop-gui/src/project/project-model.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,16 @@ export default class Project {
119119
return _.filter(this.browsers, { isChosen: false })
120120
}
121121

122+
@computed get supportedBrowsers () {
123+
return _.filter(this.browsers, (browser) => !browser.unsupportedVersion)
124+
}
125+
122126
@computed get chosenBrowser () {
123127
return _.find(this.browsers, { isChosen: true })
124128
}
125129

126130
@computed get defaultBrowser () {
127-
return this.browsers[0]
131+
return this.supportedBrowsers[0]
128132
}
129133

130134
@computed get warnings () {
@@ -173,7 +177,7 @@ export default class Project {
173177
// use a custom browser if one is supplied. or, if they already have
174178
// a browser chosen that's been saved in localStorage, then select that
175179
// otherwise just do the default.
176-
const customBrowser = _.find(this.browsers, { custom: true })
180+
const customBrowser = _.find(this.supportedBrowsers, { custom: true })
177181

178182
if (customBrowser) {
179183
return this.setChosenBrowser(customBrowser, { save: false })
@@ -260,7 +264,7 @@ export default class Project {
260264
filter.name = ls
261265
}
262266

263-
const browser = _.find(this.browsers, filter) || this.defaultBrowser
267+
const browser = _.find(this.supportedBrowsers, filter) || this.defaultBrowser
264268

265269
this.setChosenBrowser(browser)
266270
}

0 commit comments

Comments
 (0)