From cb1a1a52c756f1e35a80751fa384ff9ce66880ed Mon Sep 17 00:00:00 2001 From: Zach Panzarino Date: Fri, 28 Aug 2020 04:52:29 -0400 Subject: [PATCH 01/26] Add docs for visibility check (#3071) Co-authored-by: Jennifer Shehane --- .../core-concepts/interacting-with-elements.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/source/guides/core-concepts/interacting-with-elements.md b/source/guides/core-concepts/interacting-with-elements.md index 9ba83f9d38..72f4967307 100644 --- a/source/guides/core-concepts/interacting-with-elements.md +++ b/source/guides/core-concepts/interacting-with-elements.md @@ -47,9 +47,7 @@ Whenever Cypress cannot interact with an element, it could fail at any of the ab ## Visibility -Cypress checks a lot of things to determine an element's visibility. - -The following calculations factor in CSS translations and transforms. +Cypress checks a lot of things to determine an element's visibility. The following calculations factor in CSS translations and transforms. ### An element is considered hidden if: @@ -57,9 +55,6 @@ The following calculations factor in CSS translations and transforms. - Its CSS property (or ancestors) is `visibility: hidden`. - Its CSS property (or ancestors) is `display: none`. - Its CSS property is `position: fixed` and it's offscreen or covered up. - -### Additionally an element is considered hidden if: - - Any of its ancestors **hides overflow**\* - AND that ancestor has a `width` or `height` of `0` - AND an element between that ancestor and the element is `position: absolute` @@ -70,7 +65,13 @@ The following calculations factor in CSS translations and transforms. - AND the element is `position: relative` - AND it is positioned outside that ancestor's bounds -\***hides overflow** means it has `overflow: hidden`, `overflow-x: hidden`, `overflow-y : hidden`, `overflow: scroll`, or `overflow: auto` +\***hides overflow** means it has `overflow: hidden`, `overflow-x: hidden`, `overflow-y: hidden`, `overflow: scroll`, or `overflow: auto` + +{% note info "Opacity" %} +Elements where the CSS property (or ancestors) is `opacity: 0` are considered hidden when {% url "asserting on the element's visibility directly" assertions#Visibility %}. + +However elements where the CSS property (or ancestors) is `opacity: 0` are considered actionable and any commands used to interact with the hidden element will perform the action. +{% endnote %} ## Disability From bf114b3b9c8ecffd8fb438075d716872105d2826 Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Fri, 6 Nov 2020 11:51:56 +0630 Subject: [PATCH 02/26] Begin writing changelog --- source/_changelogs/6.0.0.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 source/_changelogs/6.0.0.md diff --git a/source/_changelogs/6.0.0.md b/source/_changelogs/6.0.0.md new file mode 100644 index 0000000000..fd3abc3654 --- /dev/null +++ b/source/_changelogs/6.0.0.md @@ -0,0 +1,27 @@ +# 6.0.0 + +*Released 11/23/2020* + +**Summary:** + +Cypress now includes support for test retries! Similar to how Cypress will retry assertions when they fail, test retries will allow you to automatically retry a failed test prior to marking it as failed. Read our new guide on {% url "Test Retries" test-retries %} for more details. + +**Breaking Changes:** + +**{% fa fa-exclamation-triangle red %} Please read our {% url "Migration Guide" migration-guide %} which explains the changes in more detail and how to change your code to migrate to Cypress 6.0.** + +- DOM elements where the CSS style (or ancestors) are `opacity: 0` are no longer considered visible. However these are still considered {% url "actionable" interacting-with-elements %} and {% url "any action commands" interacting-with-elements#Actionability %} used to interact with the element will perform the action. This matches browser's implementation on how they regard elements with `opacity: 0`. Addresses {% issue 4474 %}. +- We removed several deprecation errors around APIs that were removed in versions of Cypress prior to 4.0.0. For a full list of all APIs affected see {% issue 8946 %}. +- We updated our HTTP status codes and reason phrases to match Node.js `http.STATUS_CODES`. If you have code that relies on a reason phrase returned, then this could affect you. Addressed in {% issue 8969 %}. + +**Features:** + +**Bugfixes:** + +**Documentation Changes:** + +- Our {% url "Migration Guide" migration-guide %} has a new section for 6.0 migration. + +**Misc:** + +**Dependency Updates** From af7da38029bc4d9f0ef0538aa5c701d05b94bd2b Mon Sep 17 00:00:00 2001 From: Jennifer Shehane Date: Fri, 6 Nov 2020 11:52:08 +0630 Subject: [PATCH 03/26] Begin writing migration guide --- source/guides/references/migration-guide.md | 45 +++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/source/guides/references/migration-guide.md b/source/guides/references/migration-guide.md index 8649b81f12..1901bfecf8 100644 --- a/source/guides/references/migration-guide.md +++ b/source/guides/references/migration-guide.md @@ -2,6 +2,51 @@ title: Migration Guide --- +# Migrating to Cypress 6.0 + +This guide details the changes and how to change your code to migrate to Cypress 6.0. {% url "See the full changelog for 6.0" changelog#6-0-0 %}. + +## Opacity visibility + +DOM elements with `opacity: 0` style are no longer considered to be visible. This includes elements with an ancestor that has `opacity: 0` since a child element can never have a computed opacity greater than that of an ancestor. + +### Assert visibility of `opacity: 0` element + +{% badge danger Before %} Failed assertion that `opacity: 0` element is not visible. + +```js +it('test', () => { + // '.hidden' has 'opacity: 0' style. + // In < 5.0 this assertion would fail + cy.get('.hidden').should('not.be.visible) +}) +``` + +{% badge success After %} Passed assertion that `opacity: 0` element is not visible. + +```js +it('test', () => { + // '.hidden' has 'opacity: 0' style. + // In 6.0 this assertion will pass + cy.get('.hidden').should('not.be.visible) +}) +``` + +Elements where the CSS property (or ancestors) is `opacity: 0` are still considered {% url "actionable" interacting-with-elements %} and {% url "any action commands" interacting-with-elements#Actionability %} used to interact with the element will perform the action. This matches browser's implementation on how they regard elements with `opacity: 0`. + +```js +it('test', () => { + // '.hidden' has 'opacity: 0' style. + // + // In all versions of Cypress, you can interact + // with elements that have 'opacity: 0' style. + cy.get('.hidden').click() // ✅ clicks on element + cy.get('.hidden').type('hi') // ✅ types into element + cy.get('.hidden').check() // ✅ checks element + cy.get('.hidden').select('yes') // ✅ selects element +}) +``` + # Migrating to Cypress 5.0 This guide details the changes and how to change your code to migrate to Cypress 5.0. {% url "See the full changelog for 5.0" changelog#5-0-0 %}. From 1e466a20af3d573c7f968973378d7f5b5c174abf Mon Sep 17 00:00:00 2001 From: Zach Bloomquist Date: Sat, 14 Nov 2020 02:57:39 -0500 Subject: [PATCH 04/26] docs(net-stubbing): rename cy.route2 to cy.http (#3322) Co-authored-by: Jennifer Shehane --- _config.yml | 1 + source/_changelogs/5.1.0.md | 4 +- source/_changelogs/5.2.0.md | 10 +-- source/_changelogs/5.3.0.md | 6 +- source/_changelogs/5.4.0.md | 6 +- source/_changelogs/5.5.0.md | 10 +-- source/_data/sidebar.yml | 2 +- source/_partial/network_stubbing_warning.md | 3 +- source/api/commands/{route2.md => http.md} | 79 +++++++++++---------- source/faq/questions/using-cypress-faq.md | 3 +- source/guides/references/experiments.md | 4 +- themes/cypress/languages/en.yml | 2 +- 12 files changed, 68 insertions(+), 62 deletions(-) rename source/api/commands/{route2.md => http.md} (85%) diff --git a/_config.yml b/_config.yml index 4d99a38ec2..e911a29375 100644 --- a/_config.yml +++ b/_config.yml @@ -67,6 +67,7 @@ alias: api/assertions/assertions.html: guides/references/assertions.html api/commands/cypress-blob.html: api/utilities/blob.html api/commands/api-server.html: api/cypress-api/cypress-server.html + api/commands/route2.html: api/commands/http.html examples/index.html: examples/examples/recipes.html diff --git a/source/_changelogs/5.1.0.md b/source/_changelogs/5.1.0.md index 5babd8a839..aa4fb62676 100644 --- a/source/_changelogs/5.1.0.md +++ b/source/_changelogs/5.1.0.md @@ -6,9 +6,9 @@ - Introducing *experimental* full network stubbing support 🎉. - With `experimentalNetworkStubbing` enabled, the `cy.route2` command is available. Addressed in {% issue 4176 %}. - - By using {% url `cy.route2()` route2 %}, your tests can intercept, modify, and wait on any type of HTTP request originating from your app, including `XMLHttpRequest`s, `fetch` requests, beacons, and subresources (like iframes and scripts). + - By using {% url `cy.route2()` http %}, your tests can intercept, modify, and wait on any type of HTTP request originating from your app, including `XMLHttpRequest`s, `fetch` requests, beacons, and subresources (like iframes and scripts). - Outgoing HTTP requests can be modified before reaching the destination server, and the HTTP response can be intercepted as well before it reaches the browser. - - See the {% url `cy.route2()` route2 %} docs for more information on how to enable this experiment. + - See the {% url `cy.route2()` http %} docs for more information on how to enable this experiment. - `cy.trigger()` now accepts an `eventConstructor` option for specifying the constructor with which to create the event to trigger. Addresses {% issue 5650 %}. **Bugfixes:** diff --git a/source/_changelogs/5.2.0.md b/source/_changelogs/5.2.0.md index 19429e0754..d06f6ef976 100644 --- a/source/_changelogs/5.2.0.md +++ b/source/_changelogs/5.2.0.md @@ -5,8 +5,8 @@ **Features:** - Added the configuration option `includeShadowDom` for enabling shadow DOM querying globally, per-suite, per-test, or programmatically. Addresses {% issue 8442 %}. -- Added a `followRedirect` option to request interception with `cy.route2()`, allowing redirects to be followed before continuing to response interception. Addresses {% issue 7967 %}. -- Added the capability to specify `delayMs` and `throttleKbps` when stubbing static responses with `cy.route2()`. Addresses {% issue 7661 %}. +- Added a `followRedirect` option to request interception with {% url "`cy.route2()`" http %}, allowing redirects to be followed before continuing to response interception. Addresses {% issue 7967 %}. +- Added the capability to specify `delayMs` and `throttleKbps` when stubbing static responses with {% url "`cy.route2()`" http %}. Addresses {% issue 7661 %}. - Installing Cypress pre-releases no longer requires setting the `CYPRESS_BINARY_INSTALL` environment variable. Addresses {% issue 8482 %}. **Performance Improvements:** @@ -29,8 +29,8 @@ **Documentation Changes:** -- Fixed examples of delaying and throttling responses with `cy.route2()`. Addresses {% issue 8489 %}. -- Added examples of using a response function with `cy.route2()`. Addresses {% issue 8468 %}. +- Fixed examples of delaying and throttling responses with {% url "`cy.route2()`" http %}. Addresses {% issue 8489 %}. +- Added examples of using a response function with {% url "`cy.route2()`" http %}. Addresses {% issue 8468 %}. - Removed unmaintained languages. English docs is the only supported language by the Cypress team. We greatly appreciate the contributions from the community for other languages, but these docs are largely stale, unmaintained, and partial. The Cypress team will seek out more scalable docs internalization implementation in the future. **Misc:** @@ -38,5 +38,5 @@ - The `experimentalShadowDomSupport` configuration flag has been removed. It is no longer necessary to enable shadow DOM testing. - Improved the error message when the subject provided to `cy.shadow()` is not a shadow host. Addresses {% issue 8530 %}. - Improved the error message when the Cypress binary is not executable. It now recommends trying to clear the cache and re-install. Addresses {% issue 8397 %}. -- Added missing type declarations for the `cy.route2()` command. +- Added missing type declarations for the {% url "`cy.route2()`" http %} command. - Updated the type declaration for `Cypress.Commands.add()`, adding `Promise` to the list of allowed return types. Addresses {% issue 7807 %}. diff --git a/source/_changelogs/5.3.0.md b/source/_changelogs/5.3.0.md index 2935f7870c..1849487fca 100644 --- a/source/_changelogs/5.3.0.md +++ b/source/_changelogs/5.3.0.md @@ -9,9 +9,9 @@ **Bugfixes:** -- Fixed a bug where `cy.route2` would not automatically JSONify an empty array handler. Addresses {% issue 8532 %}. -- Fixed a bug where objects yielded by using `cy.wait` on a `cy.route2` alias would not always have a `response` property. Addresses {% issue 8536 %}. -- Fixed an issue where `cy.route2` routes would not be able to intercept requests to HTTPS destinations on a different origin. Addresses {% issue 8487 %}. +- Fixed a bug where {% url "`cy.route2()`" http %} would not automatically JSONify an empty array handler. Addresses {% issue 8532 %}. +- Fixed a bug where objects yielded by using `cy.wait` on a {% url "`cy.route2()`" http %} alias would not always have a `response` property. Addresses {% issue 8536 %}. +- Fixed an issue where {% url "`cy.route2()`" http %} routes would not be able to intercept requests to HTTPS destinations on a different origin. Addresses {% issue 8487 %}. - Fixed an issue where subjects became `undefined` after certain assertion failures. Addresses {% issue 5763 %}. - Fixed an issue where a `cy.task` with no arguments passed would receive `null` as the first argument instead of `undefined`. Addresses {% issue 5913 %}. - Fixed an issue preventing users from passing the config-file argument when starting cypress through the node module API. Addresses {% issue 8632 %}. diff --git a/source/_changelogs/5.4.0.md b/source/_changelogs/5.4.0.md index 20358771ba..ef5f01e8a1 100644 --- a/source/_changelogs/5.4.0.md +++ b/source/_changelogs/5.4.0.md @@ -19,8 +19,8 @@ - When a command is chained after {% url "`.within()`" within %} and {% url "`cy.get()`" %} is called inside it, the scope will no longer permanently change. Fixes {% issue 2106 %}, {% issue 4672 %}, {% issue 4757 %}, and {% issue 5183 %}. - Dual commands like {% url "`cy.contains()`" contains %} when used after an {% url "`.each()`" each %} commands now query as expected. Fixes {% issue 4921 %}. - `/` is no longer added to the URL when `baseUrl` has param(s). Fixes {% issue 2101 %}. -- When using {% url "`cy.route2()`" route2 %} the route handler timeouts will no longer leak into other tests and cause random failures. Addressed in {% issue 8727 %}. -- The `request.body` is now available when using {% url "`cy.wait()`" wait %} on an aliased {% url "`cy.route2()`" route2 %} route which had not been intercepted. Fixes {% issue 8695 %}. +- When using {% url "`cy.route2()`" http %} the route handler timeouts will no longer leak into other tests and cause random failures. Addressed in {% issue 8727 %}. +- The `request.body` is now available when using {% url "`cy.wait()`" wait %} on an aliased {% url "`cy.route2()`" http %} route which had not been intercepted. Fixes {% issue 8695 %}. - Re-running failed build steps in Bitbucket will no longer create a new run on the Cypress Dashboard. Fixes {% issue 8720 %}. - The forced garbage collection timer will no longer display when using a version of Firefox newer than 80. Fixes {% issue 8725 %}. - The browser dropdown is no longer covered when opened from the Runs tab in the Test Runner. Fixed in {% issue 8745 %}. @@ -28,7 +28,7 @@ **Misc:** -- Improved type definitions for {% url "`cy.route2()`" route2 %}. Addresses {% issue 8694 %} and {% issue 8782 %}. +- Improved type definitions for {% url "`cy.route2()`" http %}. Addresses {% issue 8694 %} and {% issue 8782 %}. - The Test Runner now shows an indicator in the footer and a toast notification if there is a new version available. Addressed in {% issue 8702 %} and {% issue 8803 %}. **Dependency Updates:** diff --git a/source/_changelogs/5.5.0.md b/source/_changelogs/5.5.0.md index 7d45efa8d8..8084836279 100644 --- a/source/_changelogs/5.5.0.md +++ b/source/_changelogs/5.5.0.md @@ -10,11 +10,11 @@ **Bugfixes:** - Updated the Cypress proxy layer to proxy HTTPS traffic from non-AUT origins. Addressed in {% issue 8827 %}. - - This fixed an issue with {% url "`cy.route2()`" route2 %} where HTTPS requests to a non-AUT origin would not be intercepted as expected. -- {% url "`cy.route2()`" route2 %} now properly handles passing a method as its first argument. Fixes {% issue 8729 %}. -- Fixed an issue with {% url "`cy.route2()`" route2 %} where a "Cannot set property response of undefined" error would occasionally occur. Fixes {% issue 8858 %}. -- Headers field names passed to {% url "`cy.route2()`" route2 %} now case-insensitively match against the field names of incoming HTTP requests. Fixes {% issue 8921 %}. -- Routes that stub fixtures for binary resources (including images) made with {% url "`cy.route2()`" route2 %} now serve the correct mime-type and content. Fixes {% issue 8623 %}. + - This fixed an issue with {% url "`cy.route2()`" http %} where HTTPS requests to a non-AUT origin would not be intercepted as expected. +- {% url "`cy.route2()`" http %} now properly handles passing a method as its first argument. Fixes {% issue 8729 %}. +- Fixed an issue with {% url "`cy.route2()`" http %} where a "Cannot set property response of undefined" error would occasionally occur. Fixes {% issue 8858 %}. +- Headers field names passed to {% url "`cy.route2()`" http %} now case-insensitively match against the field names of incoming HTTP requests. Fixes {% issue 8921 %}. +- Routes that stub fixtures for binary resources (including images) made with {% url "`cy.route2()`" http %} now serve the correct mime-type and content. Fixes {% issue 8623 %}. - When {% url "`experimentalNetworkStubbing`" experiments %} is enabled, using {% url "`cy.visit()`" visit %} to URLs that redirect and set Transfer-Encoding: chunked will no longer fail in Cypress with a "Parse Error". Fixes {% issue 8497 %}. - `cypress.run()` through the {% url "Module API" module-api %} now has a `status` property in the results matching the correct CLI types (`"failed"` or `"finished"`). Addresses {% issue 8799 %}. - When a value containing an `e` character is passed to the `--ci-build-id` flag, Cypress now properly reads it as a string. Fixes {% issue 8874 %}. diff --git a/source/_data/sidebar.yml b/source/_data/sidebar.yml index eb1df1fe2a..5782f6e993 100644 --- a/source/_data/sidebar.yml +++ b/source/_data/sidebar.yml @@ -101,6 +101,7 @@ api: go: go.html hash: hash.html hover: hover.html + http: http.html invoke: invoke.html its: its.html last: last.html @@ -123,7 +124,6 @@ api: rightclick: rightclick.html root: root.html route: route.html - route2: route2.html screenshot: screenshot.html scrollintoview: scrollintoview.html scrollto: scrollto.html diff --git a/source/_partial/network_stubbing_warning.md b/source/_partial/network_stubbing_warning.md index 72777e3369..a754ba8122 100644 --- a/source/_partial/network_stubbing_warning.md +++ b/source/_partial/network_stubbing_warning.md @@ -1,5 +1,4 @@ {% note danger %} 🚨 Please be aware that Cypress only currently supports intercepting XMLHttpRequests. **Requests using the Fetch API and other types of network requests like page loads and `