From 1c50105d6eb5377e33ae1a8c6692f118a695aa6b Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Tue, 15 Nov 2022 13:05:57 -0600 Subject: [PATCH 01/26] r1 - migration guide content --- content/_changelogs/11.0.0.md | 3 + content/_changelogs/12.0.0.md | 6 +- .../writing-and-organizing-tests.md | 49 +-- content/guides/references/migration-guide.md | 383 ++++++++++++++---- 4 files changed, 332 insertions(+), 109 deletions(-) diff --git a/content/_changelogs/11.0.0.md b/content/_changelogs/11.0.0.md index 754d8b4f4f..849a41f4ce 100644 --- a/content/_changelogs/11.0.0.md +++ b/content/_changelogs/11.0.0.md @@ -71,6 +71,9 @@ which explains the breaking changes in more detail.** unauthorized calls. If you use a self-signed CA you will need to set `npm_config_ca`, `npm_config_cafile`, or `NODE_EXTRA_CA_CERTS`. Addresses [#23980](https://github.com/cypress-io/cypress/issues/23980). +- Cypress now throws an error if commands are invoked from inside a `.should()` + callback. This previously resulted in unusual and undefined behavior; it is + now explicitly an error. ###### Experimental: diff --git a/content/_changelogs/12.0.0.md b/content/_changelogs/12.0.0.md index 8d98cee796..a121935ae0 100644 --- a/content/_changelogs/12.0.0.md +++ b/content/_changelogs/12.0.0.md @@ -6,8 +6,12 @@ _Released MM/DD/YYYY_ - `experimentalSessionAndOrigin` flag has been removed and all functionality is on by default now. -- `testIsolation` defaults to `strict` now. +- The new concept of `testIsolation` has been introduced and it defaults to + `on`. - `Cookies.defaults` and `Cookies.preserveOnce` have been removed. Please update to use [`cy.session()`](/api/commands/session) to preserve session details between tests. Addresses [#21472](https://github.com/cypress-io/cypress/issues/21472). +- The` cy.server()` and` cy.route()` commands and the `Cypress.Server.defaults` + API has been removed. Use [`cy.intercept()`(/api/commands/intercept) instead. + Addressed in [#24411](https://github.com/cypress-io/cypress/pull/24411). diff --git a/content/guides/core-concepts/writing-and-organizing-tests.md b/content/guides/core-concepts/writing-and-organizing-tests.md index 511142e903..853345f36c 100644 --- a/content/guides/core-concepts/writing-and-organizing-tests.md +++ b/content/guides/core-concepts/writing-and-organizing-tests.md @@ -619,19 +619,8 @@ and `off`. ###### On Mode - - - -Experimental - -`on` mode is currently experimental and can be enabled by setting -the [`experimentalSessionAndOrigin`](/guides/references/experiments) flag -to `true` in the Cypress config. This is the default test isolation behavior -when using the `experimentalSessionAndOrigin` experiment. - - - -When in `on` mode, Cypress resets the browser context _before_ each test by: +This is the default test isolation behavior in Cypress. When in `on` mode, +Cypress resets the browser context _before_ each test by: - clearing the dom state by visiting `about:blank` - clearing [cookies](/api/cypress-api/cookies) in all domains @@ -652,28 +641,17 @@ is so tests can reliably pass when run standalone or in a randomized order. ###### Off Mode - - - -Experimental - -`off` mode is currently experimental and can be enabled by setting -the [`experimentalSessionAndOrigin`](/guides/references/experiments) flag -to `true` in the Cypress config. - - - When in `off` mode, Cypress will not alter the browser context before the test starts. The page does not clear between tests and cookies, local storage and session storage will be available across tests in that suite. Additionally, the `cy.session()` command will only clear the current browser context when establishing the browser session - the current page will not clear. -It is important to note that turning test isolation `off` may improve the -overall performance of end-to-end tests, however, previous tests could be impact -the browser state. It is important to be extremely mindful of how test are -written when using this mode and ensure tests continue to run independent from -one other. +It is important to note that while turning test isolation `off` may improve the +overall performance of end-to-end tests, previous tests could be impact the +browser state. It is important to be extremely mindful of how test are written +when using this mode and ensure tests continue to run independent from one +other. ###### Mode Comparison @@ -686,13 +664,16 @@ one other. Cypress only support testIsolation `on` in component testing. -When running component tests, the browser context will allow start in a clean -slate because Cypress will +When running component tests, Cypress resets the browser context _before_ each +test by: -- clear the page -- clear [cookies](/api/cypress-api/cookies) -- clear +- clearing the page +- clearing [cookies](/api/cypress-api/cookies) +- clearing [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) +- clearing + [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) + in all domains ### Test Configuration diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index 2ef6fcb79c..d10005cd75 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -2,6 +2,315 @@ title: Migration Guide --- +## Migrating to Cypress version 12.0 + +This guide details the changes and how to change your code to migrate to Cypress +version 11.0. +[See the full changelog for version 11.0](/guides/references/changelog#11-0-0). + +The `experimentalSessionAndOrigin` flag has been removed and all functionality +associated with the Session and Origin Experiment are now available. The +`cy.origin()` and `cy.session()` commands are generally available and the +concept of Test Isolation has been introduced. + +### Test Isolation + +The +[`testIsolation`](/guides/core-concepts/writing-and-organizing-tests#Test-Isolation) +config option defaults to `on`. This means Cypress resets the browser context +_before_ each test by: + +- clearing the dom state by visiting `about:blank` +- clearing [cookies](/api/cypress-api/cookies) in all domains +- clearing + [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) + in all domains +- clearing + [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) + in all domains + +Test suites that relied on the application to persist between tests may have to +be updated to revisit their application and rebuild the browser state for each +test that needs it. + +Before this change, it was possible to write tests such that you could rely on +the application (i.e. DOM state) to persist between tests. For example you could +log in to a CMS in the first test, change some content in the second test, +verify the new version is displayed on a different URL in the third, and log out +in the fourth. + +Here's a simplified example of such a test strategy. + +Before Multiple small tests against different +origins + +```js +it('logs in', () => { + cy.visit('https://supersecurelogons.com') + cy.get('input#password').type('Password123!') + cy.get('button#submit').click() +}) + +it('updates the content', () => { + // already on page redirect from clicking button#submit + cy.get('#current-user').contains('logged in') + cy.get('button#edit-1').click() + cy.get('input#title').type('Updated title') + cy.get('button#submit').click() + cy.get('.toast').type('Changes saved!') +}) + +it('validates the change', () => { + cy.visit('/items/1') + cy.get('h1').contains('Updated title') +}) +``` + +After migrating, when `testIsolation='on'`, this flow would need to be contained +within a single test. While the above practice has always been +[discouraged](/guides/references/best-practices#Having-tests-rely-on-the-state-of-previous-tests) +we know some users have historically written tests this way, often to get around +the `same-origin` restrictions. But with `cy.origin()` you no longer need these +kind of brittle hacks, as your multi-origin logic can all reside in a single +test, like the following. + +After One big test using `cy.origin()` + +```js +it('securely edits content', () => { + cy.origin('supersecurelogons.com', () => { + cy.visit('https://supersecurelogons.com') + cy.get('input#password').type('Password123!') + cy.get('button#submit').click() + }) + + cy.origin('mycms.com', () => { + cy.url().should('contain', 'cms') + cy.get('#current-user').contains('logged in') + cy.get('button#edit-1').click() + cy.get('input#title').type('Updated title') + cy.get('button#submit').click() + cy.get('.toast').type('Changes saved!') + }) + + cy.visit('/items/1') + cy.get('h1').contains('Updated title') +}) +``` + +The just-release `cy.session()` command can be used to setup and cache cookies, +local storage and session storage between tests to easily re-establish the +previous (or common) browser contexts needed in a suite. This command will run +setup on the initial execution and will restore the saved browser state on each +sequential command execution. This command reduces the need for repeated +application logins, while users also benefit from the test isolation guardrails +to write independent, reliable and deterministic tests from the start. + +If for whatever reason you still need to persist the dom and browser context +between tests, you can set `testIsolation='off` on the root configuration or at +the suite-level. For example: + +```js +describe('workflow', { testIsolation: 'off' }, () => { + ... +}) +``` + +It is important to note that while turning test isolation `off` may improve the +overall performance of end-to-end tests, previous tests could be impact the +browser state. It is important to be extremely mindful of how test are written +when using this mode and ensure tests continue to run independent from one +other. + +For examplethe following tests are not independent +nor deterministic: + +```js +describe('workflow', { testIsolation: 'off' }, () => { + it('logs in', () => { + cy.visit('my-app.com/log-in) + cy.get('username').type('User1') + cy.get('password').type(Cypress.env('User1_password')) + cy.get('button#login').click() + cy.contains('User1') + }) + + it('clicks user profile', () => { + cy.get('User1').find('#profile_avatar).click() + cy.contains('Email Preferences') + }) + + it('updates profile', () => { + cy.get('button#edit') + cy.get('email').type('user1@email.com') + cy.get('button#save').click() + }) +}) +``` + +In the above example, each test is relying on the previous test to be +_successful_ to correctly execute. If at any point, the first or second test +fails, the sequential test(s) will automatically fail and provided un-reliable +debugging errors since the errors are representative of the previous test. + +The best way to ensure your tests are independent is to add a `.only()` to your +test and verify it can run successfully without the test before it. + +### Alias Behaviors Changes + +Cypress always re-queries aliases when they are referenced. This can result in +certain tests that use to pass failing. For example, + +```js +cy.findByTestId('popover') + .findByRole('button', { expanded: true }) + .as('button') + .click() + +cy.get('@button').should('have.attr', 'aria-expanded', 'false') +``` + +previously passed, because the initial button was collapsed when first queried, +and then later expanded. However, in Cypress 12, this test fails because the +alias is always re-queried from the DOM, effectively resulting in the following +execution: + +```js +cy.findByTestId('popover').findByRole('button', { expanded: true }).click() + +cy.findByTestId('popover') + .findByRole('button', { expanded: true }) // A button which matches here (is expanded)... + .should('have.attr', 'aria-expanded', 'false') // ...will never pass this assertion. +``` + +You can rewrite tests like this to be more specific; in our case, we changed the +alias to be the first button rather than the unexpanded button. + +```js +cy.findByTestId('popover').findAllByRole('button').first().as('button') +``` + +### Command / Cypress API Changes + +### `Cypress.Cookies.defaults` and `Cypress.Cookies.preserveOnce` + +The `Cypress.Cookies.defaults` and `CypressCookies.preserveOnce` APIs been +removed. Use the [`cy.session()`](/api/commands/session) command to preserve +cookies (and local and session storage) between tests. + +```diff +describe('Dashboard', () => { + beforeEach(() => { +- cy.login() +- Cypress.Cookies.preserveOnce('session_id', 'remember_token') ++ cy.session('unique_identifier', cy.login, { ++ validate () { ++ cy.getCookies().should('have.length', 2) ++ }, ++ cacheAcrossSpecs: true ++ }) + }) +``` + +#### `cy.server()`, `cy.route()` and `Cypress.Server.defaults` + +The` cy.server()` and` cy.route()` commands and the `Cypress.server.defaults` +API has been removed. Use the [`cy.intercept()`(/api/commands/intercept) command +instead. + +```diff + it('can encode + decode headers', () => { +- Cypress.Server.defaults({ +- delay: 500, +- method: 'GET', +- }) +- cy.server() +- cy.route(/api/, () => { +- return { +- 'test': 'We’ll', +- } +- }).as('getApi') ++ cy.intercept('GET', /api/, (req) => { ++ req.on('response', (res) => { ++ res.setDelay(500) ++ }) ++ req.body.'test': 'We’ll' ++ }).as('getApi') + cy.visit('/index.html') + cy.window().then((win) => { + const xhr = new win.XMLHttpRequest + xhr.open('GET', '/api/v1/foo/bar?a=42') + xhr.send() + }) + + cy.wait('@getApi') +- .its('url').should('include', 'api/v1') ++ .its('request.url').should('include', 'api/v1') + }) +``` + +### cy.invoke() + +`.invoke()` now throws an error if the function returns a promise. If you wish +to call a method that returns a promise and wait for it to resolve, use +`.then()` instead of `.invoke()`. + +```diff +cy.wrap(myAPI) +- .invoke('makeARequest', 'http://example.com') ++ .then(api => api.makeARequest('http://example.com')) + .then(res => { ...handle response... }) +``` + +If `.invoke()` is followed by additional commands or assertions, it will call +the named function multiple times. This has the benefit that the chained +assertions can more reliably use the function's return value. + +If this behavior is undesirable because you expect the function to invoked only +once, break the command chain and move the chains commands and/or assertions to +their own chain. For example, rewrite + +```diff +- cy.get('input').invoke('val', 'text').type('newText') ++ cy.get('input').invoke('val', 'text') ++ cy.get('input').type('newText') +``` + +#### `Cypress.Commands.override()` + +The follow commands can no longer be overridden: + +- .as() +- .children() +- .closest() +- .contains() +- cy.debug() +- cy.document() +- .eq() +- .filter() +- .find() +- .first() +- .focused() +- .get() +- .hash() +- .its() +- .last() +- cy.location() +- .next() +- .nextAll() +- .not() +- .parent() +- .parents() +- .parentsUntil() +- .prev() +- .prevUntil() +- cy.root() +- .shadow() +- .siblings() +- cy.title() +- cy.url() +- cy.window() + ## Migrating to Cypress version 11.0 This guide details the changes and how to change your code to migrate to Cypress @@ -268,80 +577,6 @@ export default defineConfig({ Vite 3+ users could make use of the [`mergeConfig`](https://vitejs.dev/guide/api-javascript.html#mergeconfig) API. -## Migrating to Cypress version 11.0 - -This guide details the changes and how to change your code to migrate to Cypress -version 11.0. -[See the full changelog for version 11.0](/guides/references/changelog#11-0-0). - -### Test Isolation - -The `testIsolation` config option defaults to `strict`. This means that after -every test, the current page is reset to `about:blank` and all active session -data (cookies, `localStorage` and `sessionStorage`) across all domains are -cleared. Some test suites that rely on the previous behavior may have to be -updated. - -Before this change, it was possible to write tests such that you could, for -example, log in to a CMS in the first test, change some content in the second -test, verify the new version is displayed on a different URL in the third, and -log out in the fourth. Here's a simplified example of such a test strategy. - -Before Multiple small tests against different -origins - -```js -it('logs in', () => { - cy.visit('https://supersecurelogons.com') - cy.get('input#password').type('Password123!') - cy.get('button#submit').click() -}) -it('updates the content', () => { - cy.get('#current-user').contains('logged in') - cy.get('button#edit-1').click() - cy.get('input#title').type('Updated title') - cy.get('button#submit').click() - cy.get('.toast').type('Changes saved!') -}) -it('validates the change', () => { - cy.visit('/items/1') - cy.get('h1').contains('Updated title') -}) -``` - -After migrating, this flow would need to be contained within a single test. -While the above practice has always been -[discouraged](/guides/references/best-practices#Having-tests-rely-on-the-state-of-previous-tests) -we know some users have historically written tests this way, often to get around -the same-origin restrictions. But with `cy.origin()` you no longer need these -kind of brittle hacks, as your multi-origin logic can all reside in a single -test, like the following. - -After One big test using `cy.origin()` - -```js -it('securely edits content', () => { - cy.origin('supersecurelogons.com', () => { - cy.visit('https://supersecurelogons.com') - cy.get('input#password').type('Password123!') - cy.get('button#submit').click() - }) - cy.origin('mycms.com', () => { - cy.url().should('contain', 'cms') - cy.get('#current-user').contains('logged in') - cy.get('button#edit-1').click() - cy.get('input#title').type('Updated title') - cy.get('button#submit').click() - cy.get('.toast').type('Changes saved!') - }) - cy.visit('/items/1') - cy.get('h1').contains('Updated title') -}) -``` - -Always remember, -[Cypress tests are not unit tests](https://docs.cypress.io/guides/references/best-practices#Creating-tiny-tests-with-a-single-assertion). - ## Migrating to Cypress version 10.0 This guide details the changes and how to change your code to migrate to Cypress From 5e1a18a9707ddc08254fc29e1e8be2993c07467d Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Wed, 16 Nov 2022 09:36:25 -0600 Subject: [PATCH 02/26] r2 - remove test isolation experimental reference --- .../core-concepts/writing-and-organizing-tests.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/content/guides/core-concepts/writing-and-organizing-tests.md b/content/guides/core-concepts/writing-and-organizing-tests.md index 853345f36c..85ccdde7b2 100644 --- a/content/guides/core-concepts/writing-and-organizing-tests.md +++ b/content/guides/core-concepts/writing-and-organizing-tests.md @@ -564,17 +564,6 @@ it.skip('returns "fizz" when number is multiple of 3', () => { ### Test Isolation - - - -Experimental - -The concept of test isolation is currently experimental, and can be enabled by -setting the [`experimentalSessionAndOrigin`](/guides/references/experiments) -option to `true` in the Cypress config. - - - **Best Practice:** Tests should From 2435390877dd237df2b4151d74e074cf46ece859 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Mon, 21 Nov 2022 15:58:20 -0600 Subject: [PATCH 03/26] include should in v12 changes --- content/_changelogs/11.0.0.md | 3 -- content/_changelogs/12.0.0.md | 3 ++ content/guides/references/migration-guide.md | 32 +++++++++++++++++++- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/content/_changelogs/11.0.0.md b/content/_changelogs/11.0.0.md index 849a41f4ce..754d8b4f4f 100644 --- a/content/_changelogs/11.0.0.md +++ b/content/_changelogs/11.0.0.md @@ -71,9 +71,6 @@ which explains the breaking changes in more detail.** unauthorized calls. If you use a self-signed CA you will need to set `npm_config_ca`, `npm_config_cafile`, or `NODE_EXTRA_CA_CERTS`. Addresses [#23980](https://github.com/cypress-io/cypress/issues/23980). -- Cypress now throws an error if commands are invoked from inside a `.should()` - callback. This previously resulted in unusual and undefined behavior; it is - now explicitly an error. ###### Experimental: diff --git a/content/_changelogs/12.0.0.md b/content/_changelogs/12.0.0.md index a121935ae0..67001a4eca 100644 --- a/content/_changelogs/12.0.0.md +++ b/content/_changelogs/12.0.0.md @@ -8,6 +8,9 @@ _Released MM/DD/YYYY_ on by default now. - The new concept of `testIsolation` has been introduced and it defaults to `on`. +- Cypress now throws an error if commands are invoked from inside a `.should()` + callback. This previously resulted in unusual and undefined behavior; it is + now explicitly an error. - `Cookies.defaults` and `Cookies.preserveOnce` have been removed. Please update to use [`cy.session()`](/api/commands/session) to preserve session details between tests. Addresses diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index d10005cd75..ba73d59694 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -249,7 +249,7 @@ instead. }) ``` -### cy.invoke() +### `.invoke()` `.invoke()` now throws an error if the function returns a promise. If you wish to call a method that returns a promise and wait for it to resolve, use @@ -276,6 +276,36 @@ their own chain. For example, rewrite + cy.get('input').type('newText') ``` +### `.should()` + +`.should()` now throws an error if Cypress commands are invoked from inside a +`.should()` callback. This previously resulted in unusual and undefined +behavior. If you wish to execute series of commands on the yield value, +use`.then()` instead. + +```diff +cy.get('button') +- .should(($button) => { + + }) ++ .then(api => api.makeARequest('http://example.com')) + .then(res => { ...handle response... }) +``` + +If `.invoke()` is followed by additional commands or assertions, it will call +the named function multiple times. This has the benefit that the chained +assertions can more reliably use the function's return value. + +If this behavior is undesirable because you expect the function to invoked only +once, break the command chain and move the chains commands and/or assertions to +their own chain. For example, rewrite + +```diff +- .invoke('val', 'text').type('newText') ++ cy.get('input').invoke('val', 'text') ++ cy.get('input').type('newText') +``` + #### `Cypress.Commands.override()` The follow commands can no longer be overridden: From e998b1dc4b044ab3900f99e00f6ffc6a4f46810c Mon Sep 17 00:00:00 2001 From: Ben M Date: Tue, 29 Nov 2022 09:23:36 -0500 Subject: [PATCH 04/26] Update 12.0.0.md updated version number --- content/_changelogs/12.0.0.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/_changelogs/12.0.0.md b/content/_changelogs/12.0.0.md index 67001a4eca..58151442cb 100644 --- a/content/_changelogs/12.0.0.md +++ b/content/_changelogs/12.0.0.md @@ -1,4 +1,4 @@ -## 11.0.0 +## 12.0.0 _Released MM/DD/YYYY_ From 48d480764c34840c705112104060784bbdb291bb Mon Sep 17 00:00:00 2001 From: Ben M Date: Tue, 29 Nov 2022 09:25:54 -0500 Subject: [PATCH 05/26] Update writing-and-organizing-tests.md removed the word "recently" that was describing a talk we gave 4 years ago --- content/guides/core-concepts/writing-and-organizing-tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/core-concepts/writing-and-organizing-tests.md b/content/guides/core-concepts/writing-and-organizing-tests.md index 85ccdde7b2..e2a2c27559 100644 --- a/content/guides/core-concepts/writing-and-organizing-tests.md +++ b/content/guides/core-concepts/writing-and-organizing-tests.md @@ -17,7 +17,7 @@ title: Writing and Organizing Tests Best Practices -We recently gave a "Best Practices" conference talk at AssertJS (February 2018). +We gave a "Best Practices" conference talk at AssertJS (February 2018). This video demonstrates how to approach breaking down your application and organizing your tests. From 4c82587e1011a6b696762f9993c86e7a8279bb52 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Tue, 29 Nov 2022 08:27:26 -0600 Subject: [PATCH 06/26] Update content/guides/references/migration-guide.md Co-authored-by: Matt Schile --- content/guides/references/migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index ba73d59694..9bdbb2c996 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -6,7 +6,7 @@ title: Migration Guide This guide details the changes and how to change your code to migrate to Cypress version 11.0. -[See the full changelog for version 11.0](/guides/references/changelog#11-0-0). +[See the full changelog for version 12.0](/guides/references/changelog#12-0-0). The `experimentalSessionAndOrigin` flag has been removed and all functionality associated with the Session and Origin Experiment are now available. The From 05fb3e35bd1407a455d458148a132e4b04763fff Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Tue, 29 Nov 2022 08:27:34 -0600 Subject: [PATCH 07/26] Update content/guides/references/migration-guide.md Co-authored-by: Matt Schile --- content/guides/references/migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index 9bdbb2c996..5368925074 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -9,7 +9,7 @@ version 11.0. [See the full changelog for version 12.0](/guides/references/changelog#12-0-0). The `experimentalSessionAndOrigin` flag has been removed and all functionality -associated with the Session and Origin Experiment are now available. The +associated with the Session and Origin experiments are now available. The `cy.origin()` and `cy.session()` commands are generally available and the concept of Test Isolation has been introduced. From 820f1344e306612203a054ffe9872aa2e1b63827 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Tue, 29 Nov 2022 08:27:46 -0600 Subject: [PATCH 08/26] Update content/guides/references/migration-guide.md Co-authored-by: Matt Schile --- content/guides/references/migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index 5368925074..9d86f0df0c 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -5,7 +5,7 @@ title: Migration Guide ## Migrating to Cypress version 12.0 This guide details the changes and how to change your code to migrate to Cypress -version 11.0. +version 12.0. [See the full changelog for version 12.0](/guides/references/changelog#12-0-0). The `experimentalSessionAndOrigin` flag has been removed and all functionality From c35e709be915293b24161b1fec413a385cf31f5c Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Tue, 29 Nov 2022 13:45:02 -0600 Subject: [PATCH 09/26] . --- content/guides/references/migration-guide.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index 9d86f0df0c..a938684980 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -2,7 +2,7 @@ title: Migration Guide --- -## Migrating to Cypress version 12.0 +## Migrating to Cypress 12.0 This guide details the changes and how to change your code to migrate to Cypress version 12.0. @@ -341,7 +341,7 @@ The follow commands can no longer be overridden: - cy.url() - cy.window() -## Migrating to Cypress version 11.0 +## Migrating to Cypress 11.0 This guide details the changes and how to change your code to migrate to Cypress version 11.0. @@ -607,7 +607,7 @@ export default defineConfig({ Vite 3+ users could make use of the [`mergeConfig`](https://vitejs.dev/guide/api-javascript.html#mergeconfig) API. -## Migrating to Cypress version 10.0 +## Migrating to Cypress 10.0 This guide details the changes and how to change your code to migrate to Cypress version 10.0. From eb94eb4b9f14a8d7d6a5178dbfc06f1bc40c604a Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Tue, 29 Nov 2022 13:58:02 -0600 Subject: [PATCH 10/26] add dropped node support to migration guide --- content/guides/references/migration-guide.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index a938684980..ec4279a81d 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -13,6 +13,18 @@ associated with the Session and Origin experiments are now available. The `cy.origin()` and `cy.session()` commands are generally available and the concept of Test Isolation has been introduced. +### Node.js 14+ support + +Cypress comes bundled with its own +[Node.js version](https://github.com/cypress-io/cypress/blob/develop/.node-version). +However, installing the `cypress` npm package uses the Node.js version installed +on your system. + +Node.js 12 reached its end of life on April 30, 2022. +[See Node's release schedule](https://github.com/nodejs/Release). This Node.js +version will no longer be supported when installing Cypress. The minimum Node.js +version supported to install Cypress is Node.js 14+. + ### Test Isolation The @@ -192,7 +204,7 @@ cy.findByTestId('popover').findAllByRole('button').first().as('button') ### Command / Cypress API Changes -### `Cypress.Cookies.defaults` and `Cypress.Cookies.preserveOnce` +#### `Cypress.Cookies.defaults` and `Cypress.Cookies.preserveOnce` The `Cypress.Cookies.defaults` and `CypressCookies.preserveOnce` APIs been removed. Use the [`cy.session()`](/api/commands/session) command to preserve From 93ae48920daa4965ae9787b70005b399e8bcefc1 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Wed, 30 Nov 2022 16:20:11 -0600 Subject: [PATCH 11/26] updates / pr feedback --- content/guides/references/migration-guide.md | 133 ++++++++++--------- 1 file changed, 69 insertions(+), 64 deletions(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index ec4279a81d..61c4168f3a 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -8,10 +8,15 @@ This guide details the changes and how to change your code to migrate to Cypress version 12.0. [See the full changelog for version 12.0](/guides/references/changelog#12-0-0). -The `experimentalSessionAndOrigin` flag has been removed and all functionality -associated with the Session and Origin experiments are now available. The -`cy.origin()` and `cy.session()` commands are generally available and the -concept of Test Isolation has been introduced. +The Session and Origin experiment has been released as General Availability +(GA), meaning that we have deemed this experiment to be feature complete and +free of issues in the majority of use cases. With releasing this as GA, the +`experimentalSessionAndOrigin` flag has been removed, the +[`cy.origin()`](<(/api/commands/origin)>) and +[`cy.session()`](/api/commands/session) commands are generally available and the +concept of +[Test Isolation](/guides/core-concepts/writing-and-organizing-tests#Test-Isolation) +has been introduced. ### Node.js 14+ support @@ -82,9 +87,9 @@ After migrating, when `testIsolation='on'`, this flow would need to be contained within a single test. While the above practice has always been [discouraged](/guides/references/best-practices#Having-tests-rely-on-the-state-of-previous-tests) we know some users have historically written tests this way, often to get around -the `same-origin` restrictions. But with `cy.origin()` you no longer need these -kind of brittle hacks, as your multi-origin logic can all reside in a single -test, like the following. +the `same-origin` restrictions. But with [`cy.origin()`](/api/commands/origin) +you no longer need these kind of brittle hacks, as your multi-origin logic can +all reside in a single test, like the following. After One big test using `cy.origin()` @@ -227,8 +232,8 @@ describe('Dashboard', () => { #### `cy.server()`, `cy.route()` and `Cypress.Server.defaults` The` cy.server()` and` cy.route()` commands and the `Cypress.server.defaults` -API has been removed. Use the [`cy.intercept()`(/api/commands/intercept) command -instead. +API has been removed. Use the [`cy.intercept()`](/api/commands/intercept) +command instead. ```diff it('can encode + decode headers', () => { @@ -261,11 +266,11 @@ instead. }) ``` -### `.invoke()` +#### `.invoke()` -`.invoke()` now throws an error if the function returns a promise. If you wish -to call a method that returns a promise and wait for it to resolve, use -`.then()` instead of `.invoke()`. +[`.invoke()`](/api/commands/invoke) now throws an error if the function returns +a promise. If you wish to call a method that returns a promise and wait for it +to resolve, use [`.then()`](/api/commands/then) instead of `.invoke()`. ```diff cy.wrap(myAPI) @@ -288,12 +293,12 @@ their own chain. For example, rewrite + cy.get('input').type('newText') ``` -### `.should()` +#### `.should()` -`.should()` now throws an error if Cypress commands are invoked from inside a -`.should()` callback. This previously resulted in unusual and undefined -behavior. If you wish to execute series of commands on the yield value, -use`.then()` instead. +[`.should()`](/api/commands/should) now throws an error if Cypress commands are +invoked from inside a `.should()` callback. This previously resulted in unusual +and undefined behavior. If you wish to execute series of commands on the yield +value, use`.then()` instead. ```diff cy.get('button') @@ -304,54 +309,54 @@ cy.get('button') .then(res => { ...handle response... }) ``` -If `.invoke()` is followed by additional commands or assertions, it will call -the named function multiple times. This has the benefit that the chained -assertions can more reliably use the function's return value. - -If this behavior is undesirable because you expect the function to invoked only -once, break the command chain and move the chains commands and/or assertions to -their own chain. For example, rewrite - -```diff -- .invoke('val', 'text').type('newText') -+ cy.get('input').invoke('val', 'text') -+ cy.get('input').type('newText') -``` - #### `Cypress.Commands.override()` -The follow commands can no longer be overridden: - -- .as() -- .children() -- .closest() -- .contains() -- cy.debug() -- cy.document() -- .eq() -- .filter() -- .find() -- .first() -- .focused() -- .get() -- .hash() -- .its() -- .last() -- cy.location() -- .next() -- .nextAll() -- .not() -- .parent() -- .parents() -- .parentsUntil() -- .prev() -- .prevUntil() -- cy.root() -- .shadow() -- .siblings() -- cy.title() -- cy.url() -- cy.window() +In Cypress 12.0.0, we introduced a new command types, called queries. A query +command is a command that returns a small and fast function for getting data +from the window or DOM. This distinction is important because Cypress will retry +any queries leading up to a non-query command, and retry any assertions after a +non-query command, to ensure the yielded subject that is being tested is always +up-to-date. + +With the introduction of query commands, the following commands have been +re-categorized and can no longer be overridden with +[`Cypress.Commands.override()`](api/cypress-api/custom-commands#Overwrite-Existing-Commands): + +- [`.as()`](/api/commands/as) +- [`.children()`](/api/commands/children) +- [`.closest()`](/api/commands/closest) +- [`.contains()`](/api/commands/contains) +- [`cy.debug()`](/api/commands/debug) +- [`cy.document()`](/api/commands/document) +- [`.eq()`](/api/commands/eq) +- [`.filter()`](/api/commands/filter) +- [`.find()`](/api/commands/find) +- [`.first()`](/api/commands/first) +- [`.focused()`](/api/commands/focused) +- [`.get()`](/api/commands/get) +- [`.hash()`](/api/commands/hash) +- [`.its()`](/api/commands/its) +- [`.last()`](/api/commands/last) +- [`cy.location()`](/api/commands/location) +- [`.next()`](/api/commands/next) +- [`.nextAll()`](/api/commands/nextall) +- [`.not()`](/api/commands/not) +- [`.parent()`](/api/commands/parent) +- [`.parents()`](/api/commands/parents) +- [`.parentsUntil()`](/api/commands/parentsuntil) +- [`.prev()`](/api/commands/prev) +- [`.prevUntil()`](/api/commands/prevuntil) +- [`cy.root()`](/api/commands/root) +- [`.shadow()`](/api/commands/shadow) +- [`.siblings()`](/api/commands/siblings) +- [`cy.title()`](/api/commands/title) +- [`cy.url()`](/api/commands/url) +- [`cy.window()`](/api/commands/window) + +If you were previously overwriting one the above commands, try adding your +version as a new command using +[`Cypress.Commands.add()`](api/cypress-api/custom-commands) under a different +name. ## Migrating to Cypress 11.0 From 73a2b4a98a4152110c4ac17194003b44f6f69422 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Wed, 30 Nov 2022 16:28:04 -0600 Subject: [PATCH 12/26] use blues words --- content/guides/references/migration-guide.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index 61c4168f3a..ac6fef9bbc 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -311,12 +311,10 @@ cy.get('button') #### `Cypress.Commands.override()` -In Cypress 12.0.0, we introduced a new command types, called queries. A query -command is a command that returns a small and fast function for getting data -from the window or DOM. This distinction is important because Cypress will retry -any queries leading up to a non-query command, and retry any assertions after a -non-query command, to ensure the yielded subject that is being tested is always -up-to-date. +In Cypress 12.0.0, we introduced a new command type, called queries. A query is +a small and fast command for getting data from the window or DOM. This +distinction is important because Cypress can retry chains of queries, keeping +the yielded subject up-to-date as a page rerenders. With the introduction of query commands, the following commands have been re-categorized and can no longer be overridden with From 188825b71947dc61b6d8ea4f51e8b3e4d59ba380 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Wed, 30 Nov 2022 17:23:36 -0600 Subject: [PATCH 13/26] fix markdown --- .../guides/core-concepts/writing-and-organizing-tests.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/guides/core-concepts/writing-and-organizing-tests.md b/content/guides/core-concepts/writing-and-organizing-tests.md index e2a2c27559..8c83432952 100644 --- a/content/guides/core-concepts/writing-and-organizing-tests.md +++ b/content/guides/core-concepts/writing-and-organizing-tests.md @@ -17,9 +17,9 @@ title: Writing and Organizing Tests Best Practices -We gave a "Best Practices" conference talk at AssertJS (February 2018). -This video demonstrates how to approach breaking down your application and -organizing your tests. +We gave a "Best Practices" conference talk at AssertJS (February 2018). This +video demonstrates how to approach breaking down your application and organizing +your tests. [https://www.youtube.com/watch?v=5XQOK0v_YRE](https://www.youtube.com/watch?v=5XQOK0v_YRE) From 98a048209d771b98ad40621f66c5323fb28f336e Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Thu, 1 Dec 2022 12:12:19 -0600 Subject: [PATCH 14/26] Apply suggestions from code review Co-authored-by: Blue F --- content/guides/references/migration-guide.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index ac6fef9bbc..440e542ccf 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -309,7 +309,7 @@ cy.get('button') .then(res => { ...handle response... }) ``` -#### `Cypress.Commands.override()` +#### `Cypress.Commands.overwrite()` In Cypress 12.0.0, we introduced a new command type, called queries. A query is a small and fast command for getting data from the window or DOM. This @@ -317,8 +317,8 @@ distinction is important because Cypress can retry chains of queries, keeping the yielded subject up-to-date as a page rerenders. With the introduction of query commands, the following commands have been -re-categorized and can no longer be overridden with -[`Cypress.Commands.override()`](api/cypress-api/custom-commands#Overwrite-Existing-Commands): +re-categorized and can no longer be overwritten with +[`Cypress.Commands.overwrite()`](api/cypress-api/custom-commands#Overwrite-Existing-Commands): - [`.as()`](/api/commands/as) - [`.children()`](/api/commands/children) From 90f63b835cc1c0da5d97f91e2ad3b865619133e1 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Thu, 1 Dec 2022 14:11:32 -0600 Subject: [PATCH 15/26] Apply suggestions from code review Co-authored-by: DEBRIS APRON --- content/guides/references/migration-guide.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index 440e542ccf..e1cef975ee 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -115,10 +115,10 @@ it('securely edits content', () => { }) ``` -The just-release `cy.session()` command can be used to setup and cache cookies, +The just-released `cy.session()` command can be used to setup and cache cookies, local storage and session storage between tests to easily re-establish the previous (or common) browser contexts needed in a suite. This command will run -setup on the initial execution and will restore the saved browser state on each +setup on its initial execution and will restore the saved browser state on each sequential command execution. This command reduces the need for repeated application logins, while users also benefit from the test isolation guardrails to write independent, reliable and deterministic tests from the start. @@ -167,7 +167,7 @@ describe('workflow', { testIsolation: 'off' }, () => { In the above example, each test is relying on the previous test to be _successful_ to correctly execute. If at any point, the first or second test -fails, the sequential test(s) will automatically fail and provided un-reliable +fails, the sequential test(s) will automatically fail and provide unreliable debugging errors since the errors are representative of the previous test. The best way to ensure your tests are independent is to add a `.only()` to your @@ -176,7 +176,7 @@ test and verify it can run successfully without the test before it. ### Alias Behaviors Changes Cypress always re-queries aliases when they are referenced. This can result in -certain tests that use to pass failing. For example, +certain tests that used to pass failing. For example, ```js cy.findByTestId('popover') @@ -284,7 +284,7 @@ the named function multiple times. This has the benefit that the chained assertions can more reliably use the function's return value. If this behavior is undesirable because you expect the function to invoked only -once, break the command chain and move the chains commands and/or assertions to +once, break the command chain and move the chain's commands and/or assertions to their own chain. For example, rewrite ```diff @@ -297,7 +297,7 @@ their own chain. For example, rewrite [`.should()`](/api/commands/should) now throws an error if Cypress commands are invoked from inside a `.should()` callback. This previously resulted in unusual -and undefined behavior. If you wish to execute series of commands on the yield +and undefined behavior. If you wish to execute a series of commands on the yield value, use`.then()` instead. ```diff @@ -351,7 +351,7 @@ re-categorized and can no longer be overwritten with - [`cy.url()`](/api/commands/url) - [`cy.window()`](/api/commands/window) -If you were previously overwriting one the above commands, try adding your +If you were previously overwriting one of the above commands, try adding your version as a new command using [`Cypress.Commands.add()`](api/cypress-api/custom-commands) under a different name. From a739fc74b98755775deee7b21a066a7a485dfa51 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Thu, 1 Dec 2022 14:12:36 -0600 Subject: [PATCH 16/26] Apply suggestions from code review --- content/guides/references/migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index e1cef975ee..d68fd94ad6 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -284,7 +284,7 @@ the named function multiple times. This has the benefit that the chained assertions can more reliably use the function's return value. If this behavior is undesirable because you expect the function to invoked only -once, break the command chain and move the chain's commands and/or assertions to +once, break the command chain and move the chain'ed commands and/or assertions to their own chain. For example, rewrite ```diff From 4f6fd8e2b113ea5e60aa4cfb4179eb11189e2f53 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Thu, 1 Dec 2022 14:13:28 -0600 Subject: [PATCH 17/26] Apply suggestions from code review --- content/guides/references/migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index d68fd94ad6..fe9c161714 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -284,7 +284,7 @@ the named function multiple times. This has the benefit that the chained assertions can more reliably use the function's return value. If this behavior is undesirable because you expect the function to invoked only -once, break the command chain and move the chain'ed commands and/or assertions to +once, break the command chain and move the chained commands and/or assertions to their own chain. For example, rewrite ```diff From b0ae517121b18c7322ff4201f0f5ead911068c05 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Fri, 2 Dec 2022 09:10:57 -0600 Subject: [PATCH 18/26] Update content/guides/core-concepts/writing-and-organizing-tests.md Co-authored-by: DEBRIS APRON --- .../guides/core-concepts/writing-and-organizing-tests.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/content/guides/core-concepts/writing-and-organizing-tests.md b/content/guides/core-concepts/writing-and-organizing-tests.md index 8c83432952..08aeeca07d 100644 --- a/content/guides/core-concepts/writing-and-organizing-tests.md +++ b/content/guides/core-concepts/writing-and-organizing-tests.md @@ -637,10 +637,11 @@ session storage will be available across tests in that suite. Additionally, the establishing the browser session - the current page will not clear. It is important to note that while turning test isolation `off` may improve the -overall performance of end-to-end tests, previous tests could be impact the -browser state. It is important to be extremely mindful of how test are written -when using this mode and ensure tests continue to run independent from one -other. +overall performance of end-to-end tests, however, it can also cause state to "leak" +between tests. This can make later tests dependent on the results of earlier +tests, and potentially cause misleading test failures. It is important to be +extremely mindful of how tests are written when using this mode, and ensure +that tests continue to run independently of one another. ###### Mode Comparison From 2766b720ed46d3ef3986c69d07551578af6f9347 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Fri, 2 Dec 2022 09:11:20 -0600 Subject: [PATCH 19/26] Update content/guides/references/migration-guide.md Co-authored-by: DEBRIS APRON --- content/guides/references/migration-guide.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index fe9c161714..5ca3a89640 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -134,10 +134,11 @@ describe('workflow', { testIsolation: 'off' }, () => { ``` It is important to note that while turning test isolation `off` may improve the -overall performance of end-to-end tests, previous tests could be impact the -browser state. It is important to be extremely mindful of how test are written -when using this mode and ensure tests continue to run independent from one -other. +overall performance of end-to-end tests, however, it can also cause state to "leak" +between tests. This can make later tests dependent on the results of earlier +tests, and potentially cause misleading test failures. It is important to be +extremely mindful of how tests are written when using this mode, and ensure +that tests continue to run independently of one another. For examplethe following tests are not independent nor deterministic: From f9f731d8da490db801a0947869084c52adb4535b Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Fri, 2 Dec 2022 09:16:56 -0600 Subject: [PATCH 20/26] Apply suggestions from code review --- content/guides/references/migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index 5ca3a89640..1cb1ca5821 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -174,7 +174,7 @@ debugging errors since the errors are representative of the previous test. The best way to ensure your tests are independent is to add a `.only()` to your test and verify it can run successfully without the test before it. -### Alias Behaviors Changes +### Behavior Changes in Alias Resolution Cypress always re-queries aliases when they are referenced. This can result in certain tests that used to pass failing. For example, From e3c1bd831aa0fe8d6efc515eee02a30a226507b1 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Fri, 2 Dec 2022 09:17:08 -0600 Subject: [PATCH 21/26] Update content/guides/references/migration-guide.md Co-authored-by: DEBRIS APRON --- content/guides/references/migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index 1cb1ca5821..03c7d94186 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -284,7 +284,7 @@ If `.invoke()` is followed by additional commands or assertions, it will call the named function multiple times. This has the benefit that the chained assertions can more reliably use the function's return value. -If this behavior is undesirable because you expect the function to invoked only +If this behavior is undesirable because you expect the function to be invoked only once, break the command chain and move the chained commands and/or assertions to their own chain. For example, rewrite From da378464a5430ee643e79054f97f8678c6dd9b4d Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Fri, 2 Dec 2022 11:58:42 -0600 Subject: [PATCH 22/26] Update content/guides/core-concepts/writing-and-organizing-tests.md Co-authored-by: Ben M --- content/guides/core-concepts/writing-and-organizing-tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/core-concepts/writing-and-organizing-tests.md b/content/guides/core-concepts/writing-and-organizing-tests.md index 08aeeca07d..688dfbef2b 100644 --- a/content/guides/core-concepts/writing-and-organizing-tests.md +++ b/content/guides/core-concepts/writing-and-organizing-tests.md @@ -637,7 +637,7 @@ session storage will be available across tests in that suite. Additionally, the establishing the browser session - the current page will not clear. It is important to note that while turning test isolation `off` may improve the -overall performance of end-to-end tests, however, it can also cause state to "leak" +overall performance of end-to-end tests, it can however cause state to "leak" between tests. This can make later tests dependent on the results of earlier tests, and potentially cause misleading test failures. It is important to be extremely mindful of how tests are written when using this mode, and ensure From e482ae33ea4eb966f8fd680ebf5a037cbad0ee00 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Fri, 2 Dec 2022 11:59:12 -0600 Subject: [PATCH 23/26] Update content/guides/references/migration-guide.md Co-authored-by: Ben M --- content/guides/references/migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index 03c7d94186..0670a76e6e 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -134,7 +134,7 @@ describe('workflow', { testIsolation: 'off' }, () => { ``` It is important to note that while turning test isolation `off` may improve the -overall performance of end-to-end tests, however, it can also cause state to "leak" +overall performance of end-to-end tests, it can however cause state to "leak" between tests. This can make later tests dependent on the results of earlier tests, and potentially cause misleading test failures. It is important to be extremely mindful of how tests are written when using this mode, and ensure From 01f930b7c16ba8969ee49de7ca64f1d3ff5d4993 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Fri, 2 Dec 2022 11:59:55 -0600 Subject: [PATCH 24/26] Update content/guides/references/migration-guide.md --- content/guides/references/migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index 0670a76e6e..c586a8b06f 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -177,7 +177,7 @@ test and verify it can run successfully without the test before it. ### Behavior Changes in Alias Resolution Cypress always re-queries aliases when they are referenced. This can result in -certain tests that used to pass failing. For example, +certain tests that used to pass could start to fail. For example, ```js cy.findByTestId('popover') From 26d7407a9a4cc73392a08c245ad69f2be4c41eda Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Fri, 2 Dec 2022 12:00:12 -0600 Subject: [PATCH 25/26] Update content/guides/references/migration-guide.md Co-authored-by: Ben M --- content/guides/references/migration-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index c586a8b06f..83212fee86 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -298,7 +298,7 @@ their own chain. For example, rewrite [`.should()`](/api/commands/should) now throws an error if Cypress commands are invoked from inside a `.should()` callback. This previously resulted in unusual -and undefined behavior. If you wish to execute a series of commands on the yield +and undefined behavior. If you wish to execute a series of commands on the yielded value, use`.then()` instead. ```diff From ec986861139f7d79c26b6295e657d39fba38fb17 Mon Sep 17 00:00:00 2001 From: Emily Rohrbough Date: Fri, 2 Dec 2022 12:02:29 -0600 Subject: [PATCH 26/26] fix markdown --- .../core-concepts/writing-and-organizing-tests.md | 4 ++-- content/guides/references/migration-guide.md | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/content/guides/core-concepts/writing-and-organizing-tests.md b/content/guides/core-concepts/writing-and-organizing-tests.md index 688dfbef2b..587305d97b 100644 --- a/content/guides/core-concepts/writing-and-organizing-tests.md +++ b/content/guides/core-concepts/writing-and-organizing-tests.md @@ -640,8 +640,8 @@ It is important to note that while turning test isolation `off` may improve the overall performance of end-to-end tests, it can however cause state to "leak" between tests. This can make later tests dependent on the results of earlier tests, and potentially cause misleading test failures. It is important to be -extremely mindful of how tests are written when using this mode, and ensure -that tests continue to run independently of one another. +extremely mindful of how tests are written when using this mode, and ensure that +tests continue to run independently of one another. ###### Mode Comparison diff --git a/content/guides/references/migration-guide.md b/content/guides/references/migration-guide.md index 83212fee86..101f5b590f 100644 --- a/content/guides/references/migration-guide.md +++ b/content/guides/references/migration-guide.md @@ -137,8 +137,8 @@ It is important to note that while turning test isolation `off` may improve the overall performance of end-to-end tests, it can however cause state to "leak" between tests. This can make later tests dependent on the results of earlier tests, and potentially cause misleading test failures. It is important to be -extremely mindful of how tests are written when using this mode, and ensure -that tests continue to run independently of one another. +extremely mindful of how tests are written when using this mode, and ensure that +tests continue to run independently of one another. For examplethe following tests are not independent nor deterministic: @@ -284,9 +284,9 @@ If `.invoke()` is followed by additional commands or assertions, it will call the named function multiple times. This has the benefit that the chained assertions can more reliably use the function's return value. -If this behavior is undesirable because you expect the function to be invoked only -once, break the command chain and move the chained commands and/or assertions to -their own chain. For example, rewrite +If this behavior is undesirable because you expect the function to be invoked +only once, break the command chain and move the chained commands and/or +assertions to their own chain. For example, rewrite ```diff - cy.get('input').invoke('val', 'text').type('newText') @@ -298,8 +298,8 @@ their own chain. For example, rewrite [`.should()`](/api/commands/should) now throws an error if Cypress commands are invoked from inside a `.should()` callback. This previously resulted in unusual -and undefined behavior. If you wish to execute a series of commands on the yielded -value, use`.then()` instead. +and undefined behavior. If you wish to execute a series of commands on the +yielded value, use`.then()` instead. ```diff cy.get('button')