diff --git a/assets/img/examples/auth0-origin.mp4 b/assets/img/examples/auth0-origin.mp4 new file mode 100644 index 0000000000..32a7ade2a1 Binary files /dev/null and b/assets/img/examples/auth0-origin.mp4 differ diff --git a/assets/img/examples/auth0-session-restore.mp4 b/assets/img/examples/auth0-session-restore.mp4 new file mode 100644 index 0000000000..54d92b5324 Binary files /dev/null and b/assets/img/examples/auth0-session-restore.mp4 differ diff --git a/assets/img/examples/aws-cognito-origin.mp4 b/assets/img/examples/aws-cognito-origin.mp4 new file mode 100644 index 0000000000..b9594ff0d0 Binary files /dev/null and b/assets/img/examples/aws-cognito-origin.mp4 differ diff --git a/assets/img/examples/cognito-session-restore.mp4 b/assets/img/examples/cognito-session-restore.mp4 new file mode 100644 index 0000000000..413613d9ee Binary files /dev/null and b/assets/img/examples/cognito-session-restore.mp4 differ diff --git a/assets/img/examples/okta-origin.mp4 b/assets/img/examples/okta-origin.mp4 new file mode 100644 index 0000000000..3b3bb1227c Binary files /dev/null and b/assets/img/examples/okta-origin.mp4 differ diff --git a/assets/img/examples/okta-session-restore.mp4 b/assets/img/examples/okta-session-restore.mp4 new file mode 100644 index 0000000000..f20a2ad47f Binary files /dev/null and b/assets/img/examples/okta-session-restore.mp4 differ diff --git a/assets/img/guides/references/cy-method-failed-element-is-detached.png b/assets/img/guides/references/cy-method-failed-element-is-detached.png deleted file mode 100644 index 955d85023a..0000000000 Binary files a/assets/img/guides/references/cy-method-failed-element-is-detached.png and /dev/null differ diff --git a/assets/img/guides/references/cy-visit-subsequent-commands-timed-out.png b/assets/img/guides/references/cy-visit-subsequent-commands-timed-out.png new file mode 100644 index 0000000000..122f4c496f Binary files /dev/null and b/assets/img/guides/references/cy-visit-subsequent-commands-timed-out.png differ diff --git a/assets/img/guides/references/cypress-method-failed-page-updated.png b/assets/img/guides/references/cypress-method-failed-page-updated.png new file mode 100644 index 0000000000..3cc7e6bdfb Binary files /dev/null and b/assets/img/guides/references/cypress-method-failed-page-updated.png differ diff --git a/assets/img/guides/retry-ability/v10/click-twice.gif b/assets/img/guides/retry-ability/click-twice.gif similarity index 100% rename from assets/img/guides/retry-ability/v10/click-twice.gif rename to assets/img/guides/retry-ability/click-twice.gif diff --git a/assets/img/guides/retry-ability/command-assertions.png b/assets/img/guides/retry-ability/command-assertions.png new file mode 100644 index 0000000000..e9b001fc59 Binary files /dev/null and b/assets/img/guides/retry-ability/command-assertions.png differ diff --git a/assets/img/guides/retry-ability/v10/delay-click.png b/assets/img/guides/retry-ability/delay-click.png similarity index 100% rename from assets/img/guides/retry-ability/v10/delay-click.png rename to assets/img/guides/retry-ability/delay-click.png diff --git a/assets/img/guides/retry-ability/v10/eq.gif b/assets/img/guides/retry-ability/eq.gif similarity index 100% rename from assets/img/guides/retry-ability/v10/eq.gif rename to assets/img/guides/retry-ability/eq.gif diff --git a/assets/img/guides/retry-ability/v10/random-number-callback.gif b/assets/img/guides/retry-ability/random-number-callback.gif similarity index 100% rename from assets/img/guides/retry-ability/v10/random-number-callback.gif rename to assets/img/guides/retry-ability/random-number-callback.gif diff --git a/assets/img/guides/retry-ability/v10/random-number-first-attempt.png b/assets/img/guides/retry-ability/random-number-first-attempt.png similarity index 100% rename from assets/img/guides/retry-ability/v10/random-number-first-attempt.png rename to assets/img/guides/retry-ability/random-number-first-attempt.png diff --git a/assets/img/guides/retry-ability/v10/random-number.gif b/assets/img/guides/retry-ability/random-number.gif similarity index 100% rename from assets/img/guides/retry-ability/v10/random-number.gif rename to assets/img/guides/retry-ability/random-number.gif diff --git a/assets/img/guides/retry-ability/retry-assertion.gif b/assets/img/guides/retry-ability/retry-assertion.gif new file mode 100644 index 0000000000..a663d98fdd Binary files /dev/null and b/assets/img/guides/retry-ability/retry-assertion.gif differ diff --git a/assets/img/guides/retry-ability/v10/second-assertion-fails.gif b/assets/img/guides/retry-ability/second-assertion-fails.gif similarity index 100% rename from assets/img/guides/retry-ability/v10/second-assertion-fails.gif rename to assets/img/guides/retry-ability/second-assertion-fails.gif diff --git a/assets/img/guides/retry-ability/v10/adds-two-items-fails.gif b/assets/img/guides/retry-ability/v10/adds-two-items-fails.gif deleted file mode 100644 index b1cb82fbce..0000000000 Binary files a/assets/img/guides/retry-ability/v10/adds-two-items-fails.gif and /dev/null differ diff --git a/assets/img/guides/retry-ability/v10/adds-two-items-passes.gif b/assets/img/guides/retry-ability/v10/adds-two-items-passes.gif deleted file mode 100644 index 3220cba47d..0000000000 Binary files a/assets/img/guides/retry-ability/v10/adds-two-items-passes.gif and /dev/null differ diff --git a/assets/img/guides/retry-ability/v10/alternating-commands-assertions.png b/assets/img/guides/retry-ability/v10/alternating-commands-assertions.png deleted file mode 100644 index 3a31361e90..0000000000 Binary files a/assets/img/guides/retry-ability/v10/alternating-commands-assertions.png and /dev/null differ diff --git a/assets/img/guides/retry-ability/v10/combined-selectors.gif b/assets/img/guides/retry-ability/v10/combined-selectors.gif deleted file mode 100644 index 27090fae4e..0000000000 Binary files a/assets/img/guides/retry-ability/v10/combined-selectors.gif and /dev/null differ diff --git a/assets/img/guides/retry-ability/v10/command-assertions.png b/assets/img/guides/retry-ability/v10/command-assertions.png deleted file mode 100644 index c0ea8a4450..0000000000 Binary files a/assets/img/guides/retry-ability/v10/command-assertions.png and /dev/null differ diff --git a/assets/img/guides/retry-ability/v10/first-item-label.png b/assets/img/guides/retry-ability/v10/first-item-label.png deleted file mode 100644 index b8ca376c4e..0000000000 Binary files a/assets/img/guides/retry-ability/v10/first-item-label.png and /dev/null differ diff --git a/assets/img/guides/retry-ability/v10/retry-2-items.gif b/assets/img/guides/retry-ability/v10/retry-2-items.gif deleted file mode 100644 index 3f3efb951c..0000000000 Binary files a/assets/img/guides/retry-ability/v10/retry-2-items.gif and /dev/null differ diff --git a/assets/img/guides/retry-ability/v10/second-get-li.png b/assets/img/guides/retry-ability/v10/second-get-li.png deleted file mode 100644 index b18a21529a..0000000000 Binary files a/assets/img/guides/retry-ability/v10/second-get-li.png and /dev/null differ diff --git a/assets/img/guides/retry-ability/v10/second-item-label.png b/assets/img/guides/retry-ability/v10/second-item-label.png deleted file mode 100644 index f7c3477c99..0000000000 Binary files a/assets/img/guides/retry-ability/v10/second-item-label.png and /dev/null differ diff --git a/assets/img/guides/retry-ability/v10/two-items.png b/assets/img/guides/retry-ability/v10/two-items.png deleted file mode 100644 index bb30637a32..0000000000 Binary files a/assets/img/guides/retry-ability/v10/two-items.png and /dev/null differ diff --git a/content/_changelogs/11.2.0.md b/content/_changelogs/11.2.0.md index 1764626e14..9e8c352f8b 100644 --- a/content/_changelogs/11.2.0.md +++ b/content/_changelogs/11.2.0.md @@ -7,7 +7,8 @@ _Released 11/22/2022_ - Re-implemented the 'Run All Specs' for End to End Testing for running multiple tests sequentially in open mode. This feature had been previously removed in Cypress 10.0. Enable 'Run All Specs' with the new experimental flag, - `experimentalRunAllSpecs`. Please leave any feedback around 'Run All Specs' + [`experimentalRunAllSpecs`](guides/references/experiments#End-to-End-Testing). + Please leave any feedback around 'Run All Specs' [here](https://github.com/cypress-io/cypress/discussions/21628). Your feedback will help us make product decisions around the future of this feature. Addresses [#24168](https://github.com/cypress-io/cypress/issues/24168) diff --git a/content/_changelogs/12.0.0.md b/content/_changelogs/12.0.0.md new file mode 100644 index 0000000000..fa982174cb --- /dev/null +++ b/content/_changelogs/12.0.0.md @@ -0,0 +1,192 @@ +## 12.0.0 + +_Released 12/06/2022_ + +**Summary:** + +The Session and Origin Experiment is now generally available for end-to-end +testing. This means Cypress now fully supports: + +- Testing multiple origins in a single test with the new + [`cy.origin()`](/api/commands/origin) command. +- Caching and restoring cookies, + [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage), + and + [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) + between tests +- Configuring + [`testIsolation`](/guides/core-concepts/writing-and-organizing-tests#Test-Isolation) + in suites to define whether or not the browser context is cleaned or persisted + between tests + +Additionally in this release, enhancements were made to how Cypress manages DOM +element resolution to reduce the likelihood of hitting detached DOM errors due +to maintaining stale DOM references. We've updated our +[Retry-ability Guide](/guides/core-concepts/retry-ability) with all the details +if you'd like to learn more. + +Read more about 12.0 in +[our blog post](https://cypress.io/blog/2022/12/06/cypress-12-release/). + +**Breaking Changes:** + +- Cypress dropped support for Node.js 12, 15 and 17. Those versions have reached + end-of-life. Installing Cypress on your system now requires Node.js 14, 16 or + 18+. Addressed in [#24885](https://github.com/cypress-io/cypress/pull/24885). +- Cypress has always recommended writing tests in a clean context. In Cypress + 12, we enforce running tests in a clean browser context through + [test isolation](/guides/core-concepts/writing-and-organizing-tests#Test-Isolation). + This option is configurable, but is enabled by default. Whether enabled or + disabled, this changes how Cypress cleans up the browser context before each + test and you may experience test errors with this upgrade. To better + understand the full impact of this change, please review the + [migration guide](/guides/references/migration-guide#test-isolation). + - In Cypress v12, the `testIsolation` configuration values have changed from + `on` or `off` to `true` or `false`. Addressed in + [#24935](https://github.com/cypress-io/cypress/pull/24935). +- The `experimentalSessionAndOrigin` configuration option has been removed and + all functionality associated with this experiment is now enabled by default, + with the exception of using `require` and `import` with callback supplied to + the [`cy.origin()`](/api/commands/origin) command. To leverage external + dependencies in `cy.origin()` callbacks, set the new + [`e2e.experimentalOriginDependencies`](guides/references/experiments#End-to-End-Testing) + configuration option to `true`. Addresses + [#21471](https://github.com/cypress-io/cypress/issues/21471). +- The `Cookies.defaults` and `Cookies.preserveOnce` APIs have been removed. Use + the new [`cy.session()`](/api/commands/session) command to preserve cookies + between tests. Addresses + [#21472](https://github.com/cypress-io/cypress/issues/21472). +- The `cy.server()` and `cy.route()` commands have been removed. Additionally, + the corresponding `Cypress.Server.defaults` API has also been removed. Use the + [`cy.intercept()`(/api/commands/intercept) command to stub network responses + and requests. Addresses + [#22126](https://github.com/cypress-io/cypress/issues/22126). +- The Cookie commands now uses the `hostname` as the domain by default instead + of the `superdomain`. This change aligns Cypress' cookie rules with the + browser cookie rules. This may affect what cookies are returned by + [`cy.getCookie()`](/api/commands/getcookie), what cookies are set with + [`cy.setCookie()`](/api/commands/setcookie), and the cookies cleared with + [`cy.clearCookies()`](/api/commands/clearcookies). Addresses + [#363](https://github.com/cypress-io/cypress/issues/363), + [#5723](https://github.com/cypress-io/cypress/issues/5723) and + [#24526](https://github.com/cypress-io/cypress/issues/24526). +- The [`.within()`](/api/commands/within) command now requires a single subject + and throws an error if given more than one subject. This change adds + consistency around how `.within()` behaves across commands. Previously some + commands inside a `.within()` callback would silently select the first + element, while others would use all of the previously yielded subjects, and + others would throw an error. Addressed in + [#24975](https://github.com/cypress-io/cypress/pull/24975). +- Cypress now throws an error if any Cypress commands are invoked from inside a + [`.should()`](/api/commands/should) callback. This previously resulted in + unusual and undefined behavior. Addresses + [#5963](https://github.com/cypress-io/cypress/issues/5963), + [#14656](https://github.com/cypress-io/cypress/issues/14656) and + [#22587](https://github.com/cypress-io/cypress/issues/22587). +- The [`.invoke()`](/api/commands/invoke) command now throws an error if the + invoked 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()`. Addressed in + [#24417](https://github.com/cypress-io/cypress/pull/24417). +- The [`cy.request()`](/api/commands/request) command now uses + [`querystringify`](https://www.npmjs.com/package/querystringify) to stringify + & parse the `qs` options. This change aligns with how the + [`cy.visit()`](/api/commands/visit) command generates urls with query + parameters. Addressed in + [#20302](https://github.com/cypress-io/cypress/pull/20302). + +**Features:** + +- Added a new configuration option called `testIsolation`, which defaults to + `true`. This option can be set at the `e2e` or suite-level to determine + whether or not + [test isolation](/guides/core-concepts/writing-and-organizing-tests#Test-Isolation) + is enabled to ensure a clean browser context between tests. Addressed in + [#22230](https://github.com/cypress-io/cypress/pull/22230). +- The previously experimental Cypress command, + [`cy.origin()`](/api/commands/origin), is now generally available in + end-to-end testing. This command allows testing multiple origins in a single + test. Addresses [#17336](https://github.com/cypress-io/cypress/issues/17336). +- The previously experimental Cypress command, + [`cy.session()`](/api/commands/session), is now generally available. This + command caches and restores `cookies`, + [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage), + and + [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) + in order to recreate a consistent browser context between tests. Addresses + [#20977](https://github.com/cypress-io/cypress/issues/20977). +- Added a new Cypress command, + [`cy.getAllLocalStorage()`](/api/commands/getAllLocalStorage), to get + [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) + data for all origins with which the test has interacted. Addresses + [#24276](https://github.com/cypress-io/cypress/issues/24276). +- Added a new Cypress command, + [`cy.clearAllLocalStorage()`](/api/commands/clearAllLocalStorage), to clear + [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) + data for all origins with which the test has interacted. Addresses + [#24276](https://github.com/cypress-io/cypress/issues/24276). +- Added a new Cypress command, + [`cy.getAllSessionStorage()`](/api/commands/getAllSessionStorage), to get + [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) + data for all origins with which the test has interacted. Addresses + [#24276](https://github.com/cypress-io/cypress/issues/24276). +- Added a new Cypress command, + [`cy.clearAllSessionStorage()`](/api/commands/clearAllSessionStorage), to + clear + [`sessionStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage) + data for all origins with which the test has interacted. Addresses + [#24276](https://github.com/cypress-io/cypress/issues/24276). +- Added a new configuration option called + [`experimentalOriginDependencies`](guides/references/experiments#End-to-End-Testing), + which defaults to `false`. This option enables support for `require` and + `import` within the callback supplied to the + [`cy.origin()`](/api/commands/origin) command in end-to-end testing. + Previously this feature was enabled through the `experimentalSessionAndOrigin` + configuration option. `experimentalOriginDependencies` was added as a + configuration option in Cypress 12, instead of being enabled by default, due + to increased Node.js memory usage associated with this option that needs to be + addressed before making this behavior generally available. See issue + [#24976](https://github.com/cypress-io/cypress/issues/24976) for more + information. Addressed in + [#24931](https://github.com/cypress-io/cypress/pull/24931). +- Added a new `Cypress.ensure` API which provides several methods that can be + helpful when writing customs commands. Addressed in + [#24697](https://github.com/cypress-io/cypress/pull/24697). +- Added a new "Run All" button to the + [`experimentalRunAllSpecs`](guides/references/experiments#End-to-End-Testing) + experiment which enables running all spec files returned from the + `specPattern` glob or an array of globs, regardless of the specs sharing a + root folder. Addresses + [#24759](https://github.com/cypress-io/cypress/issues/24759). +- Further improved bundling in the binary to reduce startup and unzip time. + Addressed in [#24909](https://github.com/cypress-io/cypress/pull/24909) + +**Bugfixes:** + +- Fixed a regression in [10.11.0](#10-11-0) where the Launchpad no longer showed + a loading spinner on startup to indicate that it had successfully started and + was in a loading state. Fixed + [#24950](https://github.com/cypress-io/cypress/issues/24950). +- Fixed the "Create Spec from Component" capability to correctly scaffold the + component spec from a component which contains special characters in its name. + Before this change, a spec was scaffolded with either the wrong spec name or + the incorrect component import which led to invalid JS errors. Fixes + [#23492](https://github.com/cypress-io/cypress/issues/23492). +- Corrected Cypress environment variable resolution to correctly resolve + environment variables set with `npm config set`. Fixes + [#24556](https://github.com/cypress-io/cypress/issues/24556). +- When + [`experimentalRunAllSpecs=true`](guides/references/experiments#End-to-End-Testing), + the "Run N specs" directory-level buttons in the Inline Specs List now + function correctly when activated by the keyboard. Fixes + [#24762](https://github.com/cypress-io/cypress/pull/24762). +- Fixed unexpected behaviors when verifying a cookie was not returned from + [`cy.getCookie()`](/api/commands/getcookie). Now it's possible to explicitly + assert the cookie did not exist with + `cy.getCookie('foo1').should('not.exist')`. Previously users had to verify + cookies properties did not exist with `.its('value').should('equal', null)`. + Addressed in [#24203](https://github.com/cypress-io/cypress/pull/24203). +- Fixed the console output returned from clicking on an aliased intercept in the + Command Log. It now logs the yielded request/response object associated to the + intercepted call when clicked, where previously it did not log these details. + Fixed in [#24623](https://github.com/cypress-io/cypress/pull/24623). diff --git a/content/_data/sidebar.json b/content/_data/sidebar.json index 180b66ba53..97b7b59f15 100644 --- a/content/_data/sidebar.json +++ b/content/_data/sidebar.json @@ -174,7 +174,7 @@ { "title": "Svelte API", "slug": "svelte/api" - } + } ] }, { @@ -197,6 +197,10 @@ "title": "Writing and Organizing Tests", "slug": "writing-and-organizing-tests" }, + { + "title": "Test Isolation", + "slug": "test-isolation" + }, { "title": "Retry-ability", "slug": "retry-ability" @@ -321,6 +325,10 @@ "title": "Cross Browser Testing", "slug": "cross-browser-testing" }, + { + "title": "Cross Origin Testing", + "slug": "cross-origin-testing" + }, { "title": "Web Security", "slug": "web-security" @@ -479,73 +487,89 @@ } ] }, - { - "title": "Events", - "slug": "events", - "children": [ - { - "title": "Catalog of Events", - "slug": "catalog-of-events" - } - ] - }, { "title": "Assertions", - "slug": "assertions", + "slug": "commands", "children": [ { - "title": "All Assertions", + "title": "Assertions Reference", "redirect": "/guides/references/assertions" + }, + { + "title": "and", + "slug": "and" + }, + { + "title": "should", + "slug": "should" } ] }, { - "title": "Commands", + "title": "Actions", "slug": "commands", "children": [ { - "title": "and", - "slug": "and" + "title": "Actionability Guide", + "redirect": "/guides/core-concepts/interacting-with-elements" }, { - "title": "as", - "slug": "as" + "title": "clear", + "slug": "clear" }, { - "title": "blur", - "slug": "blur" + "title": "click", + "slug": "click" }, { "title": "check", "slug": "check" }, { - "title": "children", - "slug": "children" + "title": "dblclick", + "slug": "dblclick" }, { - "title": "clear", - "slug": "clear" + "title": "rightclick", + "slug": "rightclick" }, { - "title": "clearCookie", - "slug": "clearcookie" + "title": "select", + "slug": "select" }, { - "title": "clearCookies", - "slug": "clearcookies" + "title": "selectFile", + "slug": "selectfile" }, { - "title": "clearLocalStorage", - "slug": "clearlocalstorage" + "title": "trigger", + "slug": "trigger" }, { - "title": "click", - "slug": "click" + "title": "type", + "slug": "type" }, { - "title": "clock", - "slug": "clock" + "title": "uncheck", + "slug": "uncheck" + } + ] + }, + { + "title": "Queries", + "slug": "commands", + "children": [ + { + "title": "Retry-ability Guide", + "redirect": "/guides/core-concepts/retry-ability" + }, + { + "title": "as", + "slug": "as" + }, + { + "title": "children", + "slug": "children" }, { "title": "closest", @@ -555,10 +579,6 @@ "title": "contains", "slug": "contains" }, - { - "title": "dblclick", - "slug": "dblclick" - }, { "title": "debug", "slug": "debug" @@ -567,22 +587,10 @@ "title": "document", "slug": "document" }, - { - "title": "each", - "slug": "each" - }, - { - "title": "end", - "slug": "end" - }, { "title": "eq", "slug": "eq" }, - { - "title": "exec", - "slug": "exec" - }, { "title": "filter", "slug": "filter" @@ -595,14 +603,6 @@ "title": "first", "slug": "first" }, - { - "title": "fixture", - "slug": "fixture" - }, - { - "title": "focus", - "slug": "focus" - }, { "title": "focused", "slug": "focused" @@ -611,30 +611,10 @@ "title": "get", "slug": "get" }, - { - "title": "getCookie", - "slug": "getcookie" - }, - { - "title": "getCookies", - "slug": "getcookies" - }, - { - "title": "go", - "slug": "go" - }, { "title": "hash", "slug": "hash" }, - { - "title": "hover", - "slug": "hover" - }, - { - "title": "intercept", - "slug": "intercept" - }, { "title": "invoke", "slug": "invoke" @@ -651,14 +631,6 @@ "title": "location", "slug": "location" }, - { - "title": "log", - "slug": "log" - }, - { - "title": "mount", - "slug": "mount" - }, { "title": "next", "slug": "next" @@ -675,10 +647,6 @@ "title": "not", "slug": "not" }, - { - "title": "origin", - "slug": "origin" - }, { "title": "parent", "slug": "parent" @@ -691,10 +659,6 @@ "title": "parentsUntil", "slug": "parentsuntil" }, - { - "title": "pause", - "slug": "pause" - }, { "title": "prev", "slug": "prev" @@ -708,72 +672,158 @@ "slug": "prevuntil" }, { - "title": "readFile", - "slug": "readfile" + "title": "root", + "slug": "root" }, { - "title": "reload", - "slug": "reload" + "title": "shadow", + "slug": "shadow" }, { - "title": "request", - "slug": "request" + "title": "siblings", + "slug": "siblings" }, { - "title": "rightclick", - "slug": "rightclick" + "title": "title", + "slug": "title" }, { - "title": "root", - "slug": "root" + "title": "url", + "slug": "url" + }, + { + "title": "window", + "slug": "window" + } + ] + }, + { + "title": "Other Commands", + "slug": "commands", + "children": [ + { + "title": "blur", + "slug": "blur" }, { - "title": "route", - "slug": "route" + "title": "clearAllLocalStorage", + "slug": "clearalllocalstorage" }, { - "title": "screenshot", - "slug": "screenshot" + "title": "clearAllSessionStorage", + "slug": "clearallsessionstorage" }, { - "title": "scrollIntoView", - "slug": "scrollintoview" + "title": "clearCookie", + "slug": "clearcookie" }, { - "title": "scrollTo", - "slug": "scrollto" + "title": "clearCookies", + "slug": "clearcookies" }, { - "title": "select", - "slug": "select" + "title": "clearLocalStorage", + "slug": "clearlocalstorage" }, { - "title": "selectFile", - "slug": "selectfile" + "title": "clock", + "slug": "clock" }, { - "title": "server", - "slug": "server" + "title": "each", + "slug": "each" }, { - "title": "session", - "slug": "session" + "title": "end", + "slug": "end" }, { - "title": "setCookie", - "slug": "setcookie" + "title": "exec", + "slug": "exec" }, { - "title": "shadow", - "slug": "shadow" + "title": "fixture", + "slug": "fixture" }, { - "title": "should", - "slug": "should" + "title": "focus", + "slug": "focus" }, { - "title": "siblings", - "slug": "siblings" + "title": "getAllLocalStorage", + "slug": "getalllocalstorage" + }, + { + "title": "getAllSessionStorage", + "slug": "getallsessionstorage" + }, + { + "title": "getCookie", + "slug": "getcookie" + }, + { + "title": "getCookies", + "slug": "getcookies" + }, + { + "title": "go", + "slug": "go" + }, + { + "title": "hover", + "slug": "hover" + }, + { + "title": "intercept", + "slug": "intercept" + }, + { + "title": "log", + "slug": "log" + }, + { + "title": "mount", + "slug": "mount" + }, + { + "title": "origin", + "slug": "origin" + }, + { + "title": "pause", + "slug": "pause" + }, + { + "title": "readFile", + "slug": "readfile" + }, + { + "title": "reload", + "slug": "reload" + }, + { + "title": "request", + "slug": "request" + }, + { + "title": "screenshot", + "slug": "screenshot" + }, + { + "title": "scrollIntoView", + "slug": "scrollintoview" + }, + { + "title": "scrollTo", + "slug": "scrollto" + }, + { + "title": "session", + "slug": "session" + }, + { + "title": "setCookie", + "slug": "setcookie" }, { "title": "spread", @@ -803,26 +853,6 @@ "title": "tick", "slug": "tick" }, - { - "title": "title", - "slug": "title" - }, - { - "title": "trigger", - "slug": "trigger" - }, - { - "title": "type", - "slug": "type" - }, - { - "title": "uncheck", - "slug": "uncheck" - }, - { - "title": "url", - "slug": "url" - }, { "title": "viewport", "slug": "viewport" @@ -836,23 +866,29 @@ "slug": "wait" }, { - "title": "window", - "slug": "window" + "title": "wrap", + "slug": "wrap" }, { "title": "within", "slug": "within" }, - { - "title": "wrap", - "slug": "wrap" - }, { "title": "writeFile", "slug": "writefile" } ] }, + { + "title": "Events", + "slug": "events", + "children": [ + { + "title": "Catalog of Events", + "slug": "catalog-of-events" + } + ] + }, { "title": "Utilities", "slug": "utilities", @@ -892,9 +928,13 @@ "slug": "cypress-api", "children": [ { - "title": "Commands", + "title": "Custom Commands", "slug": "custom-commands" }, + { + "title": "Custom Queries", + "slug": "custom-queries" + }, { "title": "Cookies", "slug": "cookies" @@ -911,10 +951,6 @@ "title": "SelectorPlayground", "slug": "selector-playground-api" }, - { - "title": "Server", - "slug": "cypress-server" - }, { "title": "arch", "slug": "arch" diff --git a/content/api/commands/and.md b/content/api/commands/and.md index ae1953a285..42cc46e27a 100644 --- a/content/api/commands/and.md +++ b/content/api/commands/and.md @@ -2,8 +2,8 @@ title: and --- -Create an assertion. Assertions are automatically retried until they pass or -time out. +Create an assertion. Assertions are automatically retried as part of the +previous command until they pass or time out. @@ -33,7 +33,9 @@ An alias of [`.should()`](/api/commands/should) ```javascript cy.get('.err').should('be.empty').and('be.hidden') // Assert '.err' is empty & hidden + cy.contains('Login').and('be.visible') // Assert el is visible + cy.wrap({ foo: 'bar' }) .should('have.property', 'foo') // Assert 'foo' property exists .and('eq', 'bar') // Assert 'foo' property is 'bar' @@ -42,7 +44,10 @@ cy.wrap({ foo: 'bar' }) ** Incorrect Usage** ```javascript -cy.and('eq', '42') // Should not be chained off 'cy' +cy.and('eq', '42') // Can not be chained off 'cy' + +cy.get('button').click().and('be.focused') // Should not be chained off +// action commands that may update the DOM ``` ### Arguments @@ -68,8 +73,9 @@ Whatever was passed to the function is what is yielded. ### Yields [](/guides/core-concepts/introduction-to-cypress#Subject-Management) -
  • In most cases, `.and()` yields the same subject it was given from the -previous command.
  • +- In most cases, `.and()` yields the same subject it was given. +- `.and()` is an assertion, and it is _safe_ to chain further commands that use + the subject. ```javascript cy.get('nav') // yields