Skip to content

Commit 648aa50

Browse files
mschiledebrisapron
authored andcommitted
docs: remove experimentalSessionAndOrigin (#4807)
1 parent a48aff1 commit 648aa50

File tree

6 files changed

+83
-157
lines changed

6 files changed

+83
-157
lines changed

content/api/commands/origin.md

Lines changed: 2 additions & 108 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

content/api/commands/session.md

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,6 @@ The `cy.session()` command will inherit the
1515
mode value to determine whether or not the page is cleared when caching and
1616
restoring the browser context.
1717

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

5020
```javascript

content/api/commands/visit.md

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -415,23 +415,12 @@ pass.</li></List>
415415

416416
## Visiting cross-origin sites
417417

418-
<Alert type="warning">
419-
420-
<strong class="alert-header"><Icon name="exclamation-triangle"></Icon>
421-
Experimental</strong>
422-
423-
Visiting cross-origin sites will currently throw an error. It can be enabled by
424-
setting
425-
the [`experimentalSessionAndOrigin`](/guides/references/experiments) flag
426-
to `true` in the Cypress config. This will allow you to visit the cross-origin
427-
site without errors. However, to interact with the content on the cross-origin
428-
site, you must use a [`cy.origin()`](/api/commands/origin) block.
418+
After visiting a cross-origin site, to interact with the content, you must use a
419+
[`cy.origin()`](/api/commands/origin) block.
429420

430421
When visiting a cross-origin site, the `onBeforeLoad` and `onLoad` options are
431422
not supported.
432423

433-
</Alert>
434-
435424
## Command Log
436425

437426
**_Visit example application in a `beforeEach`_**
@@ -455,6 +444,7 @@ following:
455444

456445
| Version | Changes |
457446
| --------------------------------------------- | -------------------------------------------------------------------------------- |
447+
| [11.0.0](/guides/references/changelog#11-0-0) | Removed `experimentalSessionAndOrigin` reference |
458448
| [3.5.0](/guides/references/changelog#3-5-0) | Added support for options `qs` |
459449
| [3.3.0](/guides/references/changelog#3-3-0) | Added support for options `retryOnStatusCodeFailure` and `retryOnNetworkFailure` |
460450
| [3.2.0](/guides/references/changelog#3-2-0) | Added options `url`, `method`, `body`, and `headers` |

content/guides/references/configuration.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ object:
207207
| `supportFile` | `cypress/support/e2e.{js,jsx,ts,tsx}` | Path to file to load before spec files load. This file is compiled and bundled. (Pass `false` to disable) |
208208
| `specPattern` | `cypress/e2e/**/*.cy.{js,jsx,ts,tsx}` | A String or Array of glob patterns of the test files to load. |
209209
| `excludeSpecPattern` | `*.hot-update.js` | A String or Array of glob patterns used to ignore test files that would otherwise be shown in your list of tests. [Please read the notes on using this.](#excludeSpecPattern) |
210-
| `experimentalSessionAndOrigin` | `false` | Enables cross-origin and improved session support, including the [`cy.origin()`](/api/commands/origin) and [`cy.session()`](/api/commands/session) commands. This enables `testIsolation=on` by default. Only available in end-to-end testing. |
211210
| `slowTestThreshold` | `10000` | Time, in milliseconds, to consider a test "slow" during `cypress run`. A slow test will display in orange text in the default reporter. |
212211
| `testIsolation` | null | The [test isolation level](/guides/core-concepts/writing-and-organizing-tests#Test-Isolation) applied to ensure a clean slate between tests. This option is only available when `experimentalSessionAndOrigin=true`, then it defaults to `on`. Options are `on` or `off`. |
213212
| `experimentalRunAllSpecs` | `false` | Enables the "Run All Specs" UI feature, allowing the execution of multiple specs sequentially. |

content/guides/references/experiments.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,10 @@ creating `e2e` and `component` objects inside your Cypress configuration.
3939
These experiments are available to be specified inside the `e2e` configuration
4040
object:
4141

42-
| Option | Default | Description |
43-
| ------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
44-
| `experimentalSessionAndOrigin` | `false` | Enables cross-origin and improved session support, by adding the [`cy.origin()`](/api/commands/origin) and [`cy.session()`](/api/commands/session) commands. This also enables the concept of [Test Isolation](/guides/core-concepts/writing-and-organizing-tests#Test-Isolation), which is `on` by default. |
45-
| `experimentalStudio` | `false` | Generate and save commands directly to your test suite by interacting with your app as an end user would. |
46-
| `experimentalRunAllSpecs` | `false` | Enables the "Run All Specs" UI feature, allowing the execution of multiple specs sequentially. |
42+
| Option | Default | Description |
43+
| ------------------------- | ------- | --------------------------------------------------------------------------------------------------------- |
44+
| `experimentalStudio` | `false` | Generate and save commands directly to your test suite by interacting with your app as an end user would. |
45+
| `experimentalRunAllSpecs` | `false` | Enables the "Run All Specs" UI feature, allowing the execution of multiple specs sequentially. |
4746

4847
### Component Testing
4948

content/guides/references/migration-guide.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,80 @@ export default defineConfig({
268268
Vite 3+ users could make use of the
269269
[`mergeConfig`](https://vitejs.dev/guide/api-javascript.html#mergeconfig) API.
270270

271+
## Migrating to Cypress version 11.0
272+
273+
This guide details the changes and how to change your code to migrate to Cypress
274+
version 11.0.
275+
[See the full changelog for version 11.0](/guides/references/changelog#11-0-0).
276+
277+
### Test Isolation
278+
279+
The `testIsolation` config option defaults to `strict`. This means that after
280+
every test, the current page is reset to `about:blank` and all active session
281+
data (cookies, `localStorage` and `sessionStorage`) across all domains are
282+
cleared. Some test suites that rely on the previous behavior may have to be
283+
updated.
284+
285+
Before this change, it was possible to write tests such that you could, for
286+
example, log in to a CMS in the first test, change some content in the second
287+
test, verify the new version is displayed on a different URL in the third, and
288+
log out in the fourth. Here's a simplified example of such a test strategy.
289+
290+
<Badge type="danger">Before</Badge> Multiple small tests against different
291+
origins
292+
293+
```js
294+
it('logs in', () => {
295+
cy.visit('https://supersecurelogons.com')
296+
cy.get('input#password').type('Password123!')
297+
cy.get('button#submit').click()
298+
})
299+
it('updates the content', () => {
300+
cy.get('#current-user').contains('logged in')
301+
cy.get('button#edit-1').click()
302+
cy.get('input#title').type('Updated title')
303+
cy.get('button#submit').click()
304+
cy.get('.toast').type('Changes saved!')
305+
})
306+
it('validates the change', () => {
307+
cy.visit('/items/1')
308+
cy.get('h1').contains('Updated title')
309+
})
310+
```
311+
312+
After migrating, this flow would need to be contained within a single test.
313+
While the above practice has always been
314+
[discouraged](/guides/references/best-practices#Having-tests-rely-on-the-state-of-previous-tests)
315+
we know some users have historically written tests this way, often to get around
316+
the same-origin restrictions. But with `cy.origin()` you no longer need these
317+
kind of brittle hacks, as your multi-origin logic can all reside in a single
318+
test, like the following.
319+
320+
<Badge type="success">After</Badge> One big test using `cy.origin()`
321+
322+
```js
323+
it('securely edits content', () => {
324+
cy.origin('supersecurelogons.com', () => {
325+
cy.visit('https://supersecurelogons.com')
326+
cy.get('input#password').type('Password123!')
327+
cy.get('button#submit').click()
328+
})
329+
cy.origin('mycms.com', () => {
330+
cy.url().should('contain', 'cms')
331+
cy.get('#current-user').contains('logged in')
332+
cy.get('button#edit-1').click()
333+
cy.get('input#title').type('Updated title')
334+
cy.get('button#submit').click()
335+
cy.get('.toast').type('Changes saved!')
336+
})
337+
cy.visit('/items/1')
338+
cy.get('h1').contains('Updated title')
339+
})
340+
```
341+
342+
Always remember,
343+
[Cypress tests are not unit tests](https://docs.cypress.io/guides/references/best-practices#Creating-tiny-tests-with-a-single-assertion).
344+
271345
## Migrating to Cypress version 10.0
272346

273347
This guide details the changes and how to change your code to migrate to Cypress

0 commit comments

Comments
 (0)