Skip to content

Commit 26d38c1

Browse files
authored
Merge pull request #4012 from cypress-io/8.0-release
2 parents 4e5a015 + 56e4a0c commit 26d38c1

File tree

12 files changed

+1360
-387
lines changed

12 files changed

+1360
-387
lines changed

content/_changelogs/8.0.0.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
## 8.0.0
2+
3+
_Released 07/19/2021_
4+
5+
**Summary:**
6+
7+
We've made some updates to ensure a consistent run experience across browsers.
8+
Now all browsers run via `cypress run` run headlessly, with a device pixel ratio
9+
of 1, and a screen size of 1280x720 by default.
10+
11+
**Breaking Changes:**
12+
13+
**<Icon name="exclamation-triangle" color="red"></Icon> Please read our
14+
[Migration Guide](/guides/references/migration-guide) which explains the changes
15+
in more detail and how to change your code to migrate to Cypress 8.0.**
16+
17+
- When running `cypress run` previous to 8.0, some browsers would launch headed
18+
while others were launched headless by default. Cypress now runs all browsers
19+
during `cypress run` as headless by default. Addresses
20+
[#16832](https://github.com/cypress-io/cypress/issues/16832).
21+
- The default screen size when running a headless browser has been reverted back
22+
to 1280x720 pixels (pre 7.0 behavior). Addresses
23+
[#16853](https://github.com/cypress-io/cypress/issues/16853).
24+
- When running the `--headless` Chrome browser via `cypress run`, the device
25+
pixel ratio will now be 1 by default, matching the behavior of all other
26+
browsers. This behavior can be overridden through the
27+
[browser launch API](/api/plugins/browser-launch-api#Override-the-device-pixel-ratio).
28+
Addresses [#17375](https://github.com/cypress-io/cypress/issues/17375).
29+
- Cypress now enforces version checks for browser launching and will error
30+
during `cypress run` and not allow opening the browser in `cypress open` when
31+
attempting to open unsupported browser versions. Cypress supports Chrome >=
32+
64, Firefox >= 86, and Edge >= 79. Addressed in
33+
[#17355](https://github.com/cypress-io/cypress/pull/17355).
34+
- Arguments returned from a chained function will no longer incorrectly be of
35+
type `jQuery` and instead have an `any` type. Fixes
36+
[#16669](https://github.com/cypress-io/cypress/issues/16669).
37+
- The `Cypress.ConfigOptions`, `Cypress.ResolvedConfigOptions` and
38+
`Cypress.RuntimeConfigOption` types have been updated so that `ConfigOptions`
39+
match the JSON schema. Addressed in
40+
[#17251](https://github.com/cypress-io/cypress/pull/17251).
41+
42+
**Features:**
43+
44+
- You can now configure certificate authority (CA) and client certificates to
45+
use within tests on a per-URL basis via a `clientCertificates` configuration
46+
option. See [Client certificates](/guides/references/client-certificates) for
47+
more detail.
48+
- Setting the environment variable `ELECTRON_RUN_AS_NODE` now starts Cypress as
49+
a normal Node.js process rather than an Electron process. See
50+
[Running headless tests without Xvfb](/guides/continuous-integration/introduction#Running-headless-tests-without-Xvfb)
51+
for more details. Addresses
52+
[#16505](https://github.com/cypress-io/cypress/issues/16505).
53+
54+
**Bugfixes:**
55+
56+
- `console.log` and `console.error` called within the
57+
[plugins file](/guides/core-concepts/writing-and-organizing-tests.html#Plugin-files)
58+
will now be captured in the `stdout` sent to the Cypress Dashboard, making it
59+
visible in Output logs in the Dashboard. Fixes
60+
[#7434](https://github.com/cypress-io/cypress/issues/7434).
61+
- There are several fixes for [`cy.intercept()`](/api/commands/intercept)
62+
including:
63+
- The `times` option now works correctly with `req.continue`. Fixes
64+
[#16821](https://github.com/cypress-io/cypress/issues/16821).
65+
- `localhost` is now accepted as a valid `hostname` in the `RouteMatcher`.
66+
Fixes [#17015](https://github.com/cypress-io/cypress/issues/17015).
67+
- `delay` now works correctly with a `statusCode` of 204. Fixes
68+
[#15188](https://github.com/cypress-io/cypress/issues/15188).
69+
- When using the experimental
70+
[Cypress Studio](/guides/core-concepts/cypress-studio), there should be a
71+
reduced occurrence of "Studio failed to save commands" error messages. Fixes
72+
[#14767](https://github.com/cypress-io/cypress/issues/14767).
73+
- [`cy.invoke()`](/api/commands/invoke) now retains the proper `this` context on
74+
nested object methods. Fixes
75+
[#3871](https://github.com/cypress-io/cypress/issues/3871).
76+
- We no longer trigger unnecessary snapshot re-renders when hovering over the
77+
Command Log. Fixes
78+
[#17257](https://github.com/cypress-io/cypress/issues/17257).

content/_data/sidebar.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,10 @@
312312
"title": "Configuration",
313313
"slug": "configuration"
314314
},
315+
{
316+
"title": "Client Certificates",
317+
"slug": "client-certificates"
318+
},
315319
{
316320
"title": "Proxy Configuration",
317321
"slug": "proxy-configuration"
@@ -768,10 +772,6 @@
768772
"title": "Cookies",
769773
"slug": "cookies"
770774
},
771-
{
772-
"title": "Keyboard",
773-
"slug": "keyboard-api"
774-
},
775775
{
776776
"title": "Screenshot",
777777
"slug": "screenshot-api"

content/api/plugins/browser-launch-api.md

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
title: Browser Launch API
33
---
44

5-
Before Cypress launches a browser, it gives you the opportunity to modify the browser preferences, install extensions, add and remove command-line arguments, and modify other options from your [pluginsFile](/guides/tooling/plugins-guide).
5+
Before Cypress launches a browser, it gives you the opportunity to modify the
6+
browser preferences, install extensions, add and remove command-line arguments,
7+
and modify other options from your [pluginsFile](/guides/tooling/plugins-guide).
68

79
## Syntax
810

911
<Alert type="warning">
1012

11-
⚠️ This code is part of the [plugins file](/guides/core-concepts/writing-and-organizing-tests.html#Plugin-files) and thus executes in the Node environment. You cannot call `Cypress` or `cy` commands in this file, but you do have the direct access to the file system and the rest of the operating system.
13+
⚠️ This code is part of the
14+
[plugins file](/guides/core-concepts/writing-and-organizing-tests.html#Plugin-files)
15+
and thus executes in the Node environment. You cannot call `Cypress` or `cy`
16+
commands in this file, but you do have the direct access to the file system and
17+
the rest of the operating system.
1218

1319
</Alert>
1420

@@ -37,7 +43,8 @@ An object describing the browser being launched, with the following properties:
3743

3844
**<Icon name="angle-right"></Icon> launchOptions** **_(object)_**
3945

40-
Options that can be modified to control how the browser is launched, with the following properties:
46+
Options that can be modified to control how the browser is launched, with the
47+
following properties:
4148

4249
| Property | Type | Description |
4350
| ------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -49,11 +56,16 @@ Options that can be modified to control how the browser is launched, with the fo
4956

5057
### Modify browser launch arguments, preferences, and extensions
5158

52-
Using your [pluginsFile](/guides/tooling/plugins-guide) you can tap into the `before:browser:launch` event and modify how Cypress launches the browser (e.g. modify arguments, user preferences, and extensions).
59+
Using your [pluginsFile](/guides/tooling/plugins-guide) you can tap into the
60+
`before:browser:launch` event and modify how Cypress launches the browser (e.g.
61+
modify arguments, user preferences, and extensions).
5362

54-
This event will yield you the `browser` object, which gives you information about the browser, and the `launchOptions` object, which allows you to modify how the browser is launched.
63+
This event will yield you the `browser` object, which gives you information
64+
about the browser, and the `launchOptions` object, which allows you to modify
65+
how the browser is launched.
5566

56-
The returned `launchOptions` object will become the new launch options for the browser.
67+
The returned `launchOptions` object will become the new launch options for the
68+
browser.
5769

5870
#### Modify browser launch arguments:
5971

@@ -114,7 +126,8 @@ Here are preferences available for the currently supported browsers:
114126

115127
- [Chromium-based browsers](https://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/pref_names.cc?view=markup)
116128
- [Electron](https://github.com/electron/electron/blob/master/docs/api/browser-window.md#new-browserwindowoptions)
117-
- Firefox: visit `about:config` URL within your Firefox browser to see all available preferences.
129+
- Firefox: visit `about:config` URL within your Firefox browser to see all
130+
available preferences.
118131

119132
```js
120133
// cypress/plugins/index.js
@@ -149,9 +162,15 @@ module.exports = (on, config) => {
149162

150163
### Modify Electron app switches
151164

152-
Cypress Test Runner is an Electron application, and its behavior (and the behavior of the bundled-in Electron browser) can be customized using command line switches. The supported switches depend on the Electron version, see [Electron documentation](https://www.electronjs.org/docs/api/command-line-switches).
165+
Cypress Test Runner is an Electron application, and its behavior (and the
166+
behavior of the bundled-in Electron browser) can be customized using command
167+
line switches. The supported switches depend on the Electron version, see
168+
[Electron documentation](https://www.electronjs.org/docs/api/command-line-switches).
153169

154-
You can pass Electron-specific launch arguments using the `ELECTRON_EXTRA_LAUNCH_ARGS` environment variable. For example, to disable HTTP browser cache and ignore certificate errors, you can set the environment variables before running Cypress like below:
170+
You can pass Electron-specific launch arguments using the
171+
`ELECTRON_EXTRA_LAUNCH_ARGS` environment variable. For example, to disable HTTP
172+
browser cache and ignore certificate errors, you can set the environment
173+
variables before running Cypress like below:
155174

156175
#### Linux/OSX
157176

@@ -165,23 +184,36 @@ export ELECTRON_EXTRA_LAUNCH_ARGS=--disable-http-cache --lang=es
165184
set ELECTRON_EXTRA_LAUNCH_ARGS=--disable-http-cache --lang=es
166185
```
167186

168-
Cypress already sets some the Electron command line switches internally. See file [packages/server/lib/environment.js](https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/environment.js). There is no way to see all currently set switches after Electron's launch.
187+
Cypress already sets some the Electron command line switches internally. See
188+
file
189+
[packages/server/lib/environment.js](https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/environment.js).
190+
There is no way to see all currently set switches after Electron's launch.
169191

170192
### See all Chrome browser switches
171193

172-
If you are running Cypress tests using a Chromium-based browser, you can see ALL currently set command line switches and the browser version information by opening a new tab and typing `chrome://version` url.
194+
If you are running Cypress tests using a Chromium-based browser, you can see ALL
195+
currently set command line switches and the browser version information by
196+
opening a new tab and typing `chrome://version` url.
173197

174198
<DocsImage src="/img/api/chrome-switches.png" alt="See all Chrome switches" ></DocsImage>
175199

176200
## Examples
177201

178202
### Set screen size when running headless
179203

180-
When a browser runs headless, there is no physical display. You can override the default screen size of 1920x1080 when running headless as shown below. This will affect the size of screenshots and videos taken during the run.
204+
When a browser runs headless, there is no physical display. You can override the
205+
default screen size of 1280x720 when running headless as shown below. This will
206+
affect the size of screenshots and videos taken during the run.
181207

182208
<Alert type="warning">
183209

184-
This setting changes the display size of the screen and does not affect the `viewportWidth` and `viewportHeight` set in the [configuration](/guides/references/configuration). The `viewportWidth` and `viewportHeight` only affect the size of the application under test displayed inside the Test Runner. Read the blog post [Generate High-Resolution Videos and Screenshots](https://www.cypress.io/blog/2021/03/01/generate-high-resolution-videos-and-screenshots/) for details.
210+
This setting changes the display size of the screen and does not affect the
211+
`viewportWidth` and `viewportHeight` set in the
212+
[configuration](/guides/references/configuration). The `viewportWidth` and
213+
`viewportHeight` only affect the size of the application under test displayed
214+
inside the Test Runner. Read the blog post
215+
[Generate High-Resolution Videos and Screenshots](https://www.cypress.io/blog/2021/03/01/generate-high-resolution-videos-and-screenshots/)
216+
for details.
185217

186218
</Alert>
187219

@@ -219,6 +251,24 @@ module.exports = (on, config) => {
219251
}
220252
```
221253

254+
### Override the device pixel ratio
255+
256+
```js
257+
// cypress/plugins/index.js
258+
module.exports = (on, config) => {
259+
on('before:browser:launch', (browser, launchOptions) => {
260+
if (browser.name === 'chrome' && browser.isHeadless) {
261+
// force screen to behave like retina
262+
// when running Chrome headless browsers
263+
// (2560x1440 in size by default)
264+
launchOptions.args.push('--force-device-scale-factor=2')
265+
}
266+
267+
return launchOptions
268+
})
269+
}
270+
```
271+
222272
### Start fullscreen
223273

224274
```js
@@ -242,11 +292,14 @@ module.exports = (on, config) => {
242292

243293
### Use fake video for webcam testing
244294

245-
By default, Cypress passes the Chrome command line switch to enable a fake video for a media stream. This is to better enable testing webcam functionality without having to have the necessary hardware to test.
295+
By default, Cypress passes the Chrome command line switch to enable a fake video
296+
for a media stream. This is to better enable testing webcam functionality
297+
without having to have the necessary hardware to test.
246298

247299
<DocsImage src="/img/api/browser-launch-fake-video.gif" alt="Enable fake video for testing" ></DocsImage>
248300

249-
You can however send your own video file for testing by passing a Chrome command line switch pointing to a video file.
301+
You can however send your own video file for testing by passing a Chrome command
302+
line switch pointing to a video file.
250303

251304
```js
252305
// cypress/plugins/index.js
@@ -269,7 +322,8 @@ module.exports = (on, config) => {
269322

270323
### Support unique file download mime types
271324

272-
Cypress supports a myriad of mime types when testing file downloads, but in case you have a unique one, you can add support for it.
325+
Cypress supports a myriad of mime types when testing file downloads, but in case
326+
you have a unique one, you can add support for it.
273327

274328
```js
275329
module.exports = (on) => {
@@ -299,7 +353,8 @@ module.exports = (on) => {
299353

300354
### Set a Firefox flag
301355

302-
If we need to set a particular Firefox flag, like `browser.send_pings` we can do it via preferences
356+
If we need to set a particular Firefox flag, like `browser.send_pings` we can do
357+
it via preferences
303358

304359
```js
305360
module.exports = (on) => {
@@ -313,7 +368,8 @@ module.exports = (on) => {
313368
}
314369
```
315370

316-
The above example comes from the blog post [How to Test Anchor Ping](https://glebbahmutov.com/blog/anchor-ping/).
371+
The above example comes from the blog post
372+
[How to Test Anchor Ping](https://glebbahmutov.com/blog/anchor-ping/).
317373

318374
## History
319375

content/guides/continuous-integration/introduction.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,16 @@ Cypress internally passes these Xvfb arguments, but if you are spawning your own
453453
454454
</Alert>
455455
456+
### Running headless tests without Xvfb
457+
458+
Chromium based browsers and Firefox can spawn without Xvfb when run via the `--headless` flag. If you're testing against either of those browsers using the `--browser` flag, you can opt out of Cypress spawning an X11 server by setting the environment variable [`ELECTRON_RUN_AS_NODE=1`](https://www.electronjs.org/docs/api/environment-variables#electron_run_as_node).
459+
460+
<Alert type="warning">
461+
462+
Electron cannot be run without an X11 server. Cypress's default browser is Electron and won't be able to launch if you set this environment variable. Likewise, Cypress's interactive mode (running via `cypress open`) is run via Electron and cannot be opened without an X11 server.
463+
464+
</Alert>
465+
456466
### Colors
457467
458468
If you want colors to be disabled, you can pass the `NO_COLOR` environment variable to disable colors. You may want to do this if ASCII characters or colors are not properly formatted in your CI.

0 commit comments

Comments
 (0)