Skip to content

Commit d2bcf77

Browse files
Merge branch 'v12' into content/update-session-api-docs
2 parents 7bb445b + 57975ce commit d2bcf77

26 files changed

+150
-1941
lines changed

content/_changelogs/12.0.0.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## 11.0.0
2+
3+
_Released MM/DD/YYYY_
4+
5+
**Breaking Changes:**
6+
7+
- `experimentalSessionAndOrigin` flag has been removed and all functionality is
8+
on by default now.
9+
- `testIsolation` defaults to `strict` now.
10+
- `Cookies.defaults` and `Cookies.preserveOnce` have been removed. Please update
11+
to use [`cy.session()`](/api/commands/session) to preserve session details
12+
between tests. Addresses
13+
[#21472](https://github.com/cypress-io/cypress/issues/21472).

content/_data/sidebar.json

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,6 @@
320320
{
321321
"title": "Cross Browser Testing",
322322
"slug": "cross-browser-testing"
323-
},
324-
{
325-
"title": "Web Security",
326-
"slug": "web-security"
327323
}
328324
]
329325
},
@@ -727,10 +723,6 @@
727723
"title": "root",
728724
"slug": "root"
729725
},
730-
{
731-
"title": "route",
732-
"slug": "route"
733-
},
734726
{
735727
"title": "screenshot",
736728
"slug": "screenshot"
@@ -751,10 +743,6 @@
751743
"title": "selectFile",
752744
"slug": "selectfile"
753745
},
754-
{
755-
"title": "server",
756-
"slug": "server"
757-
},
758746
{
759747
"title": "session",
760748
"slug": "session"
@@ -911,10 +899,6 @@
911899
"title": "SelectorPlayground",
912900
"slug": "selector-playground-api"
913901
},
914-
{
915-
"title": "Server",
916-
"slug": "cypress-server"
917-
},
918902
{
919903
"title": "arch",
920904
"slug": "arch"

content/api/commands/intercept.md

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,6 @@ Spy and stub network requests and responses.
1111

1212
</Alert>
1313

14-
<Alert type="bolt">
15-
16-
`cy.intercept()` is the successor to `cy.route()` as of Cypress 6.0.0. See
17-
[Comparison to `cy.route`](#Comparison-to-cy-route).
18-
19-
</Alert>
20-
2114
<Alert type="warning">
2215

2316
All intercepts are automatically cleared before every test.
@@ -1486,16 +1479,6 @@ Cypress.minimatch('http://localhost/users?_limit=3', '**/users?_limit=+(3|5)', {
14861479
// true (plus debug messages)
14871480
```
14881481

1489-
## Comparison to `cy.route()`
1490-
1491-
Unlike [cy.route()](/api/commands/route), `cy.intercept()`:
1492-
1493-
- can intercept all types of network requests including Fetch API, page loads,
1494-
XMLHttpRequests, resource loads, etc.
1495-
- does not require calling [cy.server()](/api/commands/server) before use - in
1496-
fact, `cy.server()` does not influence `cy.intercept()` at all.
1497-
- does not have method set to `GET` by default, but intercepts `*` methods.
1498-
14991482
## `cy.intercept()` and request caching
15001483

15011484
`cy.intercept()` intercepts requests at the network layer. This can cause
@@ -1597,7 +1580,6 @@ information about the request and response to the console:
15971580
- [Network Requests Guide](/guides/guides/network-requests)
15981581
- [Cypress Example Recipes](https://github.com/cypress-io/cypress-example-recipes#stubbing-and-spying)
15991582
- [Kitchen Sink Examples](https://github.com/cypress-io/cypress-example-kitchensink/blob/master/cypress/integration/2-advanced-examples/network_requests.spec.js)
1600-
- [Migrating `cy.route()` to `cy.intercept()`](/guides/references/migration-guide#Migrating-cy-route-to-cy-intercept)
16011583
<!-- TODO add examples from the resources below to `cypress-example-recipes` repo -->
16021584
- [Smart GraphQL Stubbing in Cypress](https://glebbahmutov.com/blog/smart-graphql-stubbing/)
16031585
blog post

content/api/commands/origin.md

100755100644
Lines changed: 2 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,6 @@ limitation determined by standard web security features of the browser. The
1313

1414
<Alert type="warning">
1515

16-
<strong class="alert-header"><Icon name="exclamation-triangle"></Icon>
17-
Experimental</strong>
18-
19-
The `session` API is currently experimental, and can be enabled by setting the
20-
[`experimentalSessionAndOrigin`](/guides/references/experiments) option to
21-
`true` in the Cypress config.
22-
23-
Enabling this flag does the following:
24-
25-
- It adds the `cy.session()` and [`cy.origin()`](/api/commands/origin) commands,
26-
and [`Cypress.session`](/api/cypress-api/session) API.
27-
- It adds the concept of
28-
[`testIsolation`](/guides/core-concepts/writing-and-organizing-tests#Test-Isolation)
29-
which defaults to `on`, such that:
30-
- The page is cleared (by setting it to `about:blank`).
31-
- Cookies, local storage and session storage in all domains are cleared.
32-
- It supersedes the
33-
[`Cypress.Cookies.preserveOnce()`](/api/cypress-api/cookies#Preserve-Once) and
34-
[`Cypress.Cookies.defaults()`](/api/cypress-api/cookies#Defaults) methods.
35-
- Cross-origin requests will now succeed, however, to interact with a
36-
cross-origin page you must use a `cy.origin` block.
37-
38-
Because the page is cleared at the beginning of each test by default,
39-
[`cy.visit()`](/api/commands/visit) must be explicitly called at the beginning
40-
of each test.
41-
42-
</Alert>
43-
44-
<Alert type="warning">
45-
4616
<strong class="alert-header"><Icon name="exclamation-triangle"></Icon>
4717
Obstructive Third Party Code</strong>
4818

@@ -340,9 +310,8 @@ performant. Up until now you could get around this problem by putting login code
340310
in the first test of your file, then performing subsequent tests reusing the
341311
same session.
342312

343-
However, once the `experimentalSessionAndOrigin` flag is activated, this is no
344-
longer possible, since all session state is now cleared between tests. So to
345-
avoid this overhead we recommend you leverage the
313+
However, this is no longer possible, since all session state is now cleared
314+
between tests. So to avoid this overhead we recommend you leverage the
346315
[`cy.session()`](/api/commands/session) command, which allows you to easily
347316
cache session information and reuse it across tests. So now let's enhance our
348317
custom login command with `cy.session()` for a complete syndicated login flow
@@ -385,81 +354,6 @@ and reuse it across tests.
385354

386355
## Notes
387356

388-
### Migrating existing tests
389-
390-
Enabling the `experimentalSessionAndOrigin` flag makes the test-runner work
391-
slightly differently, and some test suites that rely on the existing behaviour
392-
may have to be updated. The most important of these changes is
393-
[**test isolation**]() which defaults to `on`. This means that after every test,
394-
the current page is reset to `about:blank` and cookies, local storage and
395-
session storage in all domains are cleared before each test. This change is
396-
opt-in for now, but will be standardized in a future major release of Cypress,
397-
so eventually all tests will need to be isolated.
398-
399-
Before this change, it was possible to write tests such that you could, for
400-
example, log in to a CMS in the first test, change some content in the second
401-
test, verify the new version is displayed on a different URL in the third, and
402-
log out in the fourth. Here's a simplified example of such a test strategy.
403-
404-
<Badge type="danger">Before</Badge> Multiple small tests against different
405-
origins
406-
407-
```js
408-
it('logs in', () => {
409-
cy.visit('https://supersecurelogons.com')
410-
cy.get('input#password').type('Password123!')
411-
cy.get('button#submit').click()
412-
})
413-
414-
it('updates the content', () => {
415-
cy.get('#current-user').contains('logged in')
416-
cy.get('button#edit-1').click()
417-
cy.get('input#title').type('Updated title')
418-
cy.get('button#submit').click()
419-
cy.get('.toast').type('Changes saved!')
420-
})
421-
422-
it('validates the change', () => {
423-
cy.visit('/items/1')
424-
cy.get('h1').contains('Updated title')
425-
})
426-
```
427-
428-
After switching on `experimentalSessionAndOrigin`, this flow would need to be
429-
contained within a single test. While this practice has always been
430-
[discouraged](/guides/references/best-practices#Having-tests-rely-on-the-state-of-previous-tests)
431-
we know some users have historically written tests this way, often to get around
432-
the same-origin restrictions. But with `cy.origin()` you no longer need these
433-
kind of brittle hacks, as your multi-origin logic can all reside in a single
434-
test, like the following.
435-
436-
<Badge type="success">After</Badge> One big test using `cy.origin()`
437-
438-
```js
439-
it('securely edits content', () => {
440-
cy.origin('supersecurelogons.com', () => {
441-
cy.visit('https://supersecurelogons.com')
442-
cy.get('input#password').type('Password123!')
443-
cy.get('button#submit').click()
444-
})
445-
446-
cy.origin('mycms.com', () => {
447-
cy.url().should('contain', 'cms')
448-
cy.get('#current-user').contains('logged in')
449-
cy.get('button#edit-1').click()
450-
cy.get('input#title').type('Updated title')
451-
cy.get('button#submit').click()
452-
cy.get('.toast').type('Changes saved!')
453-
})
454-
455-
cy.visit('/items/1')
456-
cy.get('h1').contains('Updated title')
457-
})
458-
```
459-
460-
Always remember,
461-
[Cypress tests are not unit tests](https://docs.cypress.io/guides/references/best-practices#Creating-tiny-tests-with-a-single-assertion).
462-
463357
### Serialization
464358

465359
When entering a `cy.origin()` block, Cypress injects itself at runtime, with all
@@ -642,9 +536,6 @@ following Cypress commands will throw errors if used in the callback:
642536
- `cy.origin()`
643537
- [`cy.intercept()`](/api/commands/intercept)
644538
- [`cy.session()`](/api/commands/session)
645-
- [`cy.server()`](/api/commands/server)
646-
- [`cy.route()`](/api/commands/route)
647-
- [`Cypress.Cookies.preserveOnce()`](/api/cypress-api/cookies)
648539

649540
### Other limitations
650541

content/api/commands/request.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,9 @@ browser cookies.
357357
In other words, `cy.request()` transparently performs all of the underlying
358358
functions as if it came from the browser.
359359

360-
### [`cy.intercept()`](/api/commands/intercept), [`cy.server()`](/api/commands/server), and [`cy.route()`](/api/commands/route)
360+
### [`cy.intercept()`](/api/commands/intercept)
361361

362-
#### `cy.request()` sends requests to actual endpoints, bypassing those defined using `cy.route()` or `cy.intercept()`
363-
364-
`cy.server()` and any configuration passed to
365-
[`cy.server()`](/api/commands/server) has no effect on `cy.request()`.
362+
#### `cy.request()` sends requests to actual endpoints, bypassing those defined using `cy.intercept()`
366363

367364
The intention of `cy.request()` is to be used for checking endpoints on an
368365
actual, running server without having to start the front end application.

0 commit comments

Comments
 (0)