mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-11 09:40:11 -06:00
docs: WIP continue writing requirements and assertions, created Rules section
This commit is contained in:
@@ -14,7 +14,6 @@ module.exports = function yields (hexo, args) {
|
||||
const parentCmd = `${cmd} requires being chained off of <code>cy</code>`
|
||||
const childCmd = `${cmd} requires being chained off a previous command`
|
||||
const childCmdDom = `${cmd} requires being chained off a command that yields DOM element(s)`
|
||||
const dualCmd = `${cmd} can be chained off of <code>cy</code> or off a command that yeilds DOM element(s)`
|
||||
|
||||
const parentOrChild = () => {
|
||||
return (args[1] === 'cy.get' || args[1] === 'cy.focused') ? parentCmd : childCmdDom
|
||||
@@ -85,6 +84,18 @@ module.exports = function yields (hexo, args) {
|
||||
</ul>`
|
||||
}
|
||||
|
||||
const dual = () => {
|
||||
return `<ul>
|
||||
<li><p>${cmd} can be chained off of <code>cy</code> or off another command.</p></li>
|
||||
</ul>`
|
||||
}
|
||||
|
||||
const dualExistence = () => {
|
||||
return `<ul>
|
||||
<li><p>${cmd} can be chained off of <code>cy</code> or off a command that yields DOM element(s).</p></li>
|
||||
</ul>`
|
||||
}
|
||||
|
||||
const exec = () => {
|
||||
return `<ul>
|
||||
<li><p>${cmd} requires the executed system command to eventually exit.</p></li>
|
||||
@@ -129,6 +140,10 @@ module.exports = function yields (hexo, args) {
|
||||
return child()
|
||||
case 'child_dom':
|
||||
return childDom()
|
||||
case 'dual':
|
||||
return dual()
|
||||
case 'dual_existence':
|
||||
return dualExistence()
|
||||
case 'clearability':
|
||||
return clearability()
|
||||
case 'blurability':
|
||||
|
||||
@@ -66,7 +66,7 @@ module.exports = function yields (hexo, args) {
|
||||
|
||||
const none = () => {
|
||||
return `<ul>
|
||||
<li><p>${cmd} can not time out, nor can you add any assertions.</p></li>
|
||||
<li><p>${cmd} can not time out.</p></li>
|
||||
</ul>`
|
||||
}
|
||||
|
||||
|
||||
@@ -48,18 +48,6 @@ Option | Default | Description
|
||||
|
||||
{% yields same_subject .blur %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements blurability .blur %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions wait .blur %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions .blur %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Blur
|
||||
@@ -80,6 +68,20 @@ Setting `force` to `true` in the options disables checking whether the input is
|
||||
cy.get('input:first').blur({ force: true })
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements blurability .blur %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions wait .blur %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions .blur %}
|
||||
|
||||
# Notes
|
||||
|
||||
***`.blur()` can time out because your browser did not receive any blur events.***
|
||||
|
||||
@@ -60,18 +60,6 @@ Option | Default | Description
|
||||
|
||||
{% yields same_subject .check %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements checkability .check %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions actions .check %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .check %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Check
|
||||
@@ -121,6 +109,20 @@ cy.get('.action-checkboxes').should('not.be.visible') // Passes
|
||||
.check({ force: true }).should('be.checked') // Passes
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements checkability .check %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions actions .check %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .check %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**check the element with name of 'emailUser'**
|
||||
|
||||
@@ -48,18 +48,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .children %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .children %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .children %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .children %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Children
|
||||
@@ -113,6 +101,20 @@ cy.get('ul.secondary-nav').children()
|
||||
cy.get('ul').children('.active')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .children %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .children %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .children %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Assert that there should be 8 children elements in a nav**
|
||||
|
||||
@@ -52,18 +52,6 @@ Option | Default | Description
|
||||
|
||||
{% yields same_subject .clear %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements clearability .clear %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions actions .clear %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .clear %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Clear
|
||||
@@ -76,6 +64,20 @@ Prior to clearing, if the element isn't currently focused, Cypress issues a {% u
|
||||
cy.get('textarea').clear().type('Hello, World')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements clearability .clear %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions actions .clear %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .clear %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Clear the input and type a new value**
|
||||
|
||||
@@ -11,7 +11,6 @@ Cypress automatically clears all cookies *before* each test to prevent state fro
|
||||
|
||||
# Syntax
|
||||
|
||||
|
||||
```javascript
|
||||
cy.clearCookie(name)
|
||||
cy.clearCookie(name, options)
|
||||
@@ -44,18 +43,6 @@ Option | Default | Description
|
||||
|
||||
{% yields null cy.clearCookie %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.clearCookie %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.clearCookie %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.clearCookie %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Clear Cookie
|
||||
@@ -73,6 +60,20 @@ cy.visit('/dashboard') // we should be redirected back to login
|
||||
cy.url().should('include', 'login')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.clearCookie %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.clearCookie %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.clearCookie %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Clearing a cookie after setting a cookie**
|
||||
|
||||
@@ -39,18 +39,6 @@ Option | Default | Description
|
||||
|
||||
{% yields null cy.clearCookies %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.clearCookies %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.clearCookies %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.clearCookies %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Clear Cookies
|
||||
@@ -68,6 +56,20 @@ cy.visit('/dashboard') // we should be redirected back to login
|
||||
cy.url().should('include', 'login')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.clearCookies %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.clearCookies %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.clearCookies %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Clear cookies after getting cookies**
|
||||
|
||||
@@ -44,18 +44,6 @@ Option | Default | Description
|
||||
|
||||
{% yields null cy.clearLocalStorage %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.clearLocalStorage %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.clearLocalStorage %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.clearLocalStorage %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Clear Local Storage
|
||||
@@ -80,6 +68,20 @@ cy.clearLocalStorage('appName')
|
||||
cy.clearLocalStorage(/app-/)
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.clearLocalStorage %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.clearLocalStorage %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.clearLocalStorage %}
|
||||
|
||||
# Command Log
|
||||
|
||||
```javascript
|
||||
|
||||
@@ -64,18 +64,6 @@ Option | Default | Description
|
||||
|
||||
{% yields same_subject .click %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements child_dom .click %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions actions .click %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .click %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Click
|
||||
@@ -193,6 +181,20 @@ Cypress attempts to position the element onscreen by scrolling all parent elemen
|
||||
|
||||
These situations are rare, but if you're having a difficult time clicking an element or experiencing seemingly *random* failures, you will save *yourself hours of debugging and headache* by simply issuing the `{force: true}` option to the click or by inserting a small delay prior to the click with {% url 'cy.wait()' wait %}. It is almost never worth your time trying to debug finicky animation issues caused by 3rd party plugins.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements child_dom .click %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions actions .click %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .click %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Click the button in the form that has text "Create User"**
|
||||
|
||||
@@ -64,14 +64,6 @@ Option | Default | Description
|
||||
|
||||
You can also access the `clock` object via `this.clock` in a {% url `.then()` then %} callback.
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.clock %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.clock %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Clock
|
||||
@@ -189,6 +181,20 @@ Note that `cy.clock()` only applies to the `top` window on a web page. It will n
|
||||
|
||||
If you call `cy.clock()` before visiting a page with {% url `cy.visit()` visit %}, the page's native global functions will be overridden on window load, before any of your app code runs, so even if `setTimeout`, for example, is called on page load, it can still be controlled via {% url `cy.tick()` tick %}. This also applies if, during the course of a test, the page under test is reloaded or changed.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.clock %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.clock %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.clock %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Create a clock and tick it 1 second**
|
||||
|
||||
@@ -46,6 +46,18 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .closest %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Closest
|
||||
|
||||
**Find the closest element of the 'error' with the class 'banner'**
|
||||
|
||||
```javascript
|
||||
cy.get('p.error').closest('.banner')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .closest %}
|
||||
@@ -58,16 +70,6 @@ Option | Default | Description
|
||||
|
||||
{% timeouts existence .closest %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Closest
|
||||
|
||||
**Find the closest element of the 'error' with the class 'banner'**
|
||||
|
||||
```javascript
|
||||
cy.get('p.error').closest('.banner')
|
||||
```
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find the closest element of 'active li' with the class 'nav'**
|
||||
|
||||
@@ -15,8 +15,6 @@ Get the DOM element containing the text. DOM elements can contain *more* than th
|
||||
|
||||
## Usage
|
||||
|
||||
`.contains()` can be chained off of `cy` to find content within the entire document or chained off another cy command that *yields* a DOM element - limiting it's search of content to within yielded element.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -54,14 +52,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .contains %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .contains %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .contains %}
|
||||
|
||||
# Examples
|
||||
|
||||
## String
|
||||
@@ -312,6 +302,20 @@ cy.contains('Delete User').click()
|
||||
cy.get('#dialog').contains('Yes, Delete!').click()
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements dual_existence .contains %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .contains %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .contains %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Element contains text "New User"**
|
||||
|
||||
@@ -44,6 +44,18 @@ Option | Default | Description
|
||||
|
||||
{% yields same_subject .dblclick %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Double Click
|
||||
|
||||
**Double click an anchor link**
|
||||
|
||||
```javascript
|
||||
cy.get('a#nav1').dblclick() // yields the <a>
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements child_dom .dblclick %}
|
||||
@@ -56,16 +68,6 @@ Option | Default | Description
|
||||
|
||||
{% timeouts actions .dblclick %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Double Click
|
||||
|
||||
**Double click an anchor link**
|
||||
|
||||
```javascript
|
||||
cy.get('a#nav1').dblclick() // yields the <a>
|
||||
```
|
||||
|
||||
# Command Log
|
||||
|
||||
**Double click on a calendar schedule**
|
||||
|
||||
@@ -18,8 +18,6 @@ You need to have your Developer Tools open for `.debug()` to hit the breakpoint.
|
||||
|
||||
## Usage
|
||||
|
||||
`.debug()` can be chained off of `cy` or any cy command.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -41,14 +39,6 @@ Option | Default | Description
|
||||
|
||||
{% yields same_subject .debug %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements none .debug %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none .debug %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Debug
|
||||
@@ -59,6 +49,20 @@ Option | Default | Description
|
||||
cy.get('a').debug().should('have.attr', 'href')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements dual .debug %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none .debug %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none .debug %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Log out the current subject for debugging**
|
||||
|
||||
@@ -14,8 +14,6 @@ cy.document(options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.document()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -37,14 +35,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_subject cy.document 'yields the `window.document` object' %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.document %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.document %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Document
|
||||
@@ -63,6 +53,20 @@ cy.document().then(function(document) {
|
||||
cy.document().its('contentType').should('eq', 'text/html')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.document %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry cy.document %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.document %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Get the document**
|
||||
|
||||
@@ -13,8 +13,6 @@ Iterate through an array like structure (arrays or objects with a `length` prope
|
||||
|
||||
## Usage
|
||||
|
||||
`.each()` requires being chained off another cy command that *yields* an array like structure (arrays or objects with a `length` property).
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -44,14 +42,6 @@ Pass a function that is invoked with the following arguments:
|
||||
|
||||
{% yields same_subject .each %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements none .each %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none .each %}
|
||||
|
||||
# Examples
|
||||
|
||||
## DOM Elements
|
||||
@@ -110,6 +100,20 @@ cy.wrap([1,2,3]).each(function(num, i, array){
|
||||
|
||||
You can stop the `.each()` loop early by returning `false` in the callback function.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements none .each %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions once .each %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none .each %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**`cy.each()` does *not* log in the command log**
|
||||
|
||||
@@ -14,8 +14,6 @@ End a chain of commands.
|
||||
|
||||
## Usage
|
||||
|
||||
`.end()` should be chained off another cy command.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -32,14 +30,6 @@ cy.end() // Does not make sense to chain off 'cy'
|
||||
|
||||
{% yields null .end %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements none .end %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none .end %}
|
||||
|
||||
# Examples
|
||||
|
||||
`.end()` is useful when you want to end a chain of commands and force the next command to not receive what was yielded in the previous command.
|
||||
@@ -58,6 +48,20 @@ cy.contains('User: Cheryl').click()
|
||||
cy.contains('User: Charles').click() // contains looks for content in document now
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements child .end %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none .end %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none .end %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**`.end()` does *not* log in the command log**
|
||||
|
||||
@@ -53,18 +53,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .eq %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .eq %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .eq %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .eq %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Index
|
||||
@@ -103,6 +91,20 @@ cy.get('li').eq(1).should('contain', 'siamese') // true
|
||||
cy.get('li').eq(-2).should('contain', 'sphynx') // true
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .eq %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .eq %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .eq %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find the 4th `<li>` in the navigation**
|
||||
|
||||
@@ -68,18 +68,6 @@ Option | Default | Description
|
||||
- `stdout`
|
||||
- `stderr`
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements exec cy.exec %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions once cy.exec %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts exec cy.exec %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Prepping data
|
||||
@@ -169,6 +157,20 @@ cy
|
||||
|
||||
A command must exit within the `execTimeout` or Cypress will kill the command's process and fail the current test.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements exec cy.exec %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions once cy.exec %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts exec cy.exec %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**List the contents of cypress.json**
|
||||
|
||||
@@ -50,18 +50,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .filter %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .filter %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .filter %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .filter %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Selector
|
||||
@@ -83,6 +71,20 @@ Option | Default | Description
|
||||
cy.get('ul').find('>li').filter('.active')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .filter %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .filter %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .filter %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Filter the li's to the li with the class 'active'.**
|
||||
|
||||
@@ -46,18 +46,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .find %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .find %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .find %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .find %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Selector
|
||||
@@ -76,6 +64,20 @@ Option | Default | Description
|
||||
cy.get('#parent').find('li')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .find %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .find %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .find %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find the li's within the nav**
|
||||
|
||||
@@ -42,18 +42,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .first %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .first %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .find %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .first %}
|
||||
|
||||
# Examples
|
||||
|
||||
## First element
|
||||
@@ -74,6 +62,20 @@ Option | Default | Description
|
||||
cy.get('li').first()
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .first %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .find %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .first %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find the first input in the form**
|
||||
|
||||
@@ -16,8 +16,6 @@ cy.fixture(filePath, encoding, options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.fixture()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -67,14 +65,6 @@ Option | Default | Description
|
||||
|
||||
`cy.fixture()` yields the contents of the file. Formatting is determined by it's file extension.
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.fixture %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.fixture %}
|
||||
|
||||
# Examples
|
||||
|
||||
## JSON
|
||||
@@ -219,6 +209,20 @@ Cypress automatically determines the encoding for the following file types:
|
||||
|
||||
For other types of files, they will be read as `utf8` by default, unless specified in the second argument of `cy.fixture()`.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.fixture %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions once cy.fixture %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.fixture %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**`cy.fixture()` does *not* log in the command log**
|
||||
|
||||
@@ -42,18 +42,6 @@ Option | Default | Description
|
||||
|
||||
{% yields same_subject .focus %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements focusability .focus %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions wait .focus %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions .focus %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Focus
|
||||
@@ -85,6 +73,20 @@ Ensure the element you are trying to call `.focus()` on is a {% url 'focusable e
|
||||
|
||||
If you see this error, you may want to ensure that the main browser window is currently focused. This means not being focused in debugger or any other window when the command is run.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements focusability .focus %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions wait .focus %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions .focus %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Focus the textarea**
|
||||
|
||||
@@ -35,18 +35,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_dom_subject cy.focused %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence cy.focused %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence cy.focused %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence cy.focused %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Focused
|
||||
@@ -71,6 +59,20 @@ cy.focused().blur()
|
||||
cy.focused().should('have.attr', 'name', 'username')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence cy.focused %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence cy.focused %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence cy.focused %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Make an assertion on the focused element**
|
||||
|
||||
@@ -51,18 +51,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_dom_subject cy.get %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence cy.get %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence cy.get %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence cy.get %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Selector
|
||||
@@ -125,6 +113,20 @@ it('disables on click', function(){
|
||||
})
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence cy.get %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence cy.get %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence cy.get %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Get an input and assert on the value**
|
||||
|
||||
@@ -51,18 +51,6 @@ Option | Default | Description
|
||||
|
||||
`cy.getCookie()` yields `null`.
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.getCookie %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions once cy.getCookie %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.getCookie %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Get Cookie
|
||||
@@ -85,6 +73,20 @@ cy.getCookie('session_id')
|
||||
Check out our example recipes using `cy.getCookie()` to test {% url 'logging in using HTML web forms' logging-in %}, {% url 'logging in using XHR web forms' logging-in %} and {% url 'logging in with single sign on' logging-in %}
|
||||
{% endnote %}
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.getCookie %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions once cy.getCookie %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.getCookie %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Get cookie**
|
||||
|
||||
@@ -14,8 +14,6 @@ cy.getCookies(options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.getCookies()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -45,14 +43,6 @@ Option | Default | Description
|
||||
- `secure`
|
||||
- `expiry`
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.getCookies %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.getCookies %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Get Cookies
|
||||
@@ -72,6 +62,20 @@ cy.getCookies()
|
||||
})
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.getCookies %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions once cy.getCookies %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.getCookies %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Get cookies**
|
||||
|
||||
@@ -15,8 +15,6 @@ cy.go(direction, options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.go()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -44,14 +42,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_subject cy.go 'yields the `window` object after the page finishes loading' %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements page cy.go %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts page cy.go %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Back / Forward
|
||||
@@ -88,6 +78,20 @@ cy.go(1) // equivalent to clicking forward button
|
||||
|
||||
If going forward or back causes a full page refresh, Cypress will wait for the new page to load before moving on to new commands. Cypress additionally handles situations where a page load was not caused (such as hash routing) and will resolve immediately.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements page cy.go %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions wait cy.go %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts page cy.go %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Go back in browser's history**
|
||||
|
||||
@@ -47,18 +47,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_subject cy.hash "yields an empty string" %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.hash %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry cy.hash %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.hash %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Hash
|
||||
@@ -85,6 +73,20 @@ cy.get('#users li').find('a').click()
|
||||
cy.hash().should('match', /users\/.+$/) // => true
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.hash %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry cy.hash %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.hash %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Assert that the hash matches `#users/new`**
|
||||
|
||||
@@ -18,8 +18,6 @@ If you want to get a property that is not a function on the previously yielded s
|
||||
|
||||
## Usage
|
||||
|
||||
`.invoke()` requires being chained off another cy command that *yields* an object with function properties.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -48,8 +46,6 @@ Additional arguments to be given to the function call. There is no limit to the
|
||||
|
||||
{% yields changes_subject .invoke 'yields the return value of the invoked function' }
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Function
|
||||
@@ -141,6 +137,20 @@ cy
|
||||
.should('include', 'myLogo')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements child .invoke %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry .invoke %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions .invoke %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Invoke jQuery show method on element**
|
||||
|
||||
@@ -41,18 +41,6 @@ Name of property or nested properties (with dot notation) to get.
|
||||
|
||||
{% yields changes_subject .its 'yields the value of the property' %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements child .its %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions its .its %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts its .its %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Plain Objects
|
||||
@@ -143,6 +131,20 @@ var user = {
|
||||
cy.wrap(user).its('contacts.work.name').should('eq', 'Kamil') // true
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements child .its %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions its .its %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts its .its %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Get `responseBody` of aliased route**
|
||||
|
||||
@@ -42,18 +42,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .last %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .last %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .last %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .last %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Last element
|
||||
@@ -74,6 +62,20 @@ Option | Default | Description
|
||||
cy.get('li').last()
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .last %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .last %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .last %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find the last button in the form**
|
||||
|
||||
@@ -58,18 +58,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_subject cy.location 'yields the value of the location property as a string' %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.location %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry cy.location %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.location %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Location Properties
|
||||
@@ -144,6 +132,20 @@ cy.location().then(function(location){
|
||||
|
||||

|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.location %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry cy.location %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.location %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Assert on the location's href**
|
||||
|
||||
@@ -14,8 +14,6 @@ cy.log(message, args...)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.log()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -36,8 +34,6 @@ Additional arguments to be printed to the Cypress Command Log. There is no limit
|
||||
|
||||
{% yields null cy.log %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Message
|
||||
@@ -58,6 +54,20 @@ cy.log('Login successful')
|
||||
cy.log('events triggered', events)
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.log %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.log %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.log %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Print messages with arguments to the Command Log.**
|
||||
|
||||
@@ -48,18 +48,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .next %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .next %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .next %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .next %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Next
|
||||
@@ -97,6 +85,20 @@ cy.get('.second').next()
|
||||
cy.get('li').next('.selected')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .next %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .next %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .next %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find the element next to the `.active` li**
|
||||
|
||||
@@ -48,18 +48,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .nextAll %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .nextAll %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .nextAll %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .nextAll %}
|
||||
|
||||
# Examples
|
||||
|
||||
## All Next
|
||||
@@ -100,6 +88,20 @@ cy.get('.second').nextAll()
|
||||
cy.get('li').nextAll('.selected')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .nextAll %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .nextAll %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .nextAll %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find all elements following the `.active` li**
|
||||
|
||||
@@ -59,18 +59,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .nextUntil %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .nextUntil %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .nextUntil %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .nextUntil %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Selector
|
||||
@@ -99,6 +87,20 @@ Option | Default | Description
|
||||
cy.get('#veggies').nextUntil('#nuts')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .nextUntil %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .nextUntil %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .nextUntil %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find all of the element's siblings following `#veggies` until `#nuts`**
|
||||
|
||||
@@ -50,6 +50,18 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .not %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Selector
|
||||
|
||||
**Yield the elements that do not have class `active`.**
|
||||
|
||||
```javascript
|
||||
cy.get('.left-nav>li').not('.active').should('not.have.class', 'active') // true
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .not %}
|
||||
@@ -62,16 +74,6 @@ Option | Default | Description
|
||||
|
||||
{% timeouts existence .not %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Selector
|
||||
|
||||
**Yield the elements that do not have class `active`.**
|
||||
|
||||
```javascript
|
||||
cy.get('.left-nav>li').not('.active').should('not.have.class', 'active') // true
|
||||
```
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find all buttons that are not of type submit**
|
||||
|
||||
@@ -48,18 +48,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .parent %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .parent %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .parent %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .parent %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Parent
|
||||
@@ -78,6 +66,20 @@ cy.get('li.active').parent()
|
||||
cy.get('li.active').parent('.nav')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .parent %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .parent %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .parent %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Assert on the parent of the active li**
|
||||
|
||||
@@ -48,18 +48,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .parents %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .parents %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .parents %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .parents %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Parents
|
||||
@@ -78,6 +66,20 @@ cy.get('li.active').parents()
|
||||
cy.get('li.active').parents('.nav')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .parents %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .parents %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .parents %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Get the parents of the active `li`**
|
||||
|
||||
@@ -58,18 +58,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .parentsUntil %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .parentsUntil %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .parentsUntil %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .parentsUntil %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Selector
|
||||
@@ -97,6 +85,20 @@ Option | Default | Description
|
||||
cy.get('.active').parentsUntil('.nav')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .parentsUntil %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .parentsUntil %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .parentsUntil %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find all of the `active` element's ancestors until `.nav`**
|
||||
|
||||
@@ -18,8 +18,6 @@ This does not set a `debugger` in your code, unlike {% url `.debug()` debug %}
|
||||
|
||||
## Usage
|
||||
|
||||
`.pause()` can be chained off of `cy` or any cy command.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -41,8 +39,6 @@ Option | Default | Description
|
||||
|
||||
{% yields same_subject .pause %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Pause
|
||||
@@ -54,6 +50,20 @@ cy.get('a').should('have.attr', 'href').and('match', /dashboard/).pause()
|
||||
cy.get('button').should('not.be.disabled')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements dual .pause %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none .pause %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none .pause %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Pause and step through each `.click()` command**
|
||||
|
||||
@@ -48,18 +48,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .prev %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .prev %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .prev %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .prev %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Previous
|
||||
@@ -100,6 +88,20 @@ cy.get('.active').prev()
|
||||
cy.get('li').prev('.active')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .prev %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .prev %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .prev %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find the previous element of the active `li`**
|
||||
|
||||
@@ -48,18 +48,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .prevAll %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .prevAll %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .prevAll %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .prevAll %}
|
||||
|
||||
# Examples
|
||||
|
||||
## All Previous
|
||||
@@ -100,6 +88,20 @@ cy.get('.third').prevAll()
|
||||
cy.get('li').prevAll('.selected')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .prevAll %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .prevAll %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .prevAll %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find all elements before the `.active` li**
|
||||
|
||||
@@ -58,18 +58,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .prevUntil %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .prevUntil %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .prevUntil %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .prevUntil %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Selector
|
||||
@@ -98,6 +86,20 @@ Option | Default | Description
|
||||
cy.get('#nuts').prevUntil('#veggies')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .prevUntil %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .prevUntil %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .prevUntil %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Find all of the element's siblings before `#nuts` until `#veggies`**
|
||||
|
||||
@@ -57,18 +57,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_subject cy.readFile 'yields the contents of the file' %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements read_file cy.readFile %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry cy.readFile %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.readFile %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Text
|
||||
@@ -169,6 +157,20 @@ cy.readFile('does-not-exist.yaml').should('not.exist')
|
||||
cy.readFile('some/nested/path/story.txt').should('eq', 'Once upon a time...')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements read_file cy.readFile %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry cy.readFile %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.readFile %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**List the contents of cypress.json**
|
||||
|
||||
@@ -16,8 +16,6 @@ cy.reload(forceReload, options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.reload()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -41,14 +39,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_subject cy.reload 'yields the `window` object after the page finishes loading' %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements page cy.reload %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts page cy.reload %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Reload
|
||||
@@ -71,6 +61,20 @@ cy.visit('http://localhost:3000/admin')
|
||||
cy.reload(true)
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements page cy.reload %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions wait cy.reload %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts page cy.reload %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Reload the page**
|
||||
|
||||
@@ -16,8 +16,6 @@ cy.screenshot(fileName, options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.screenshot()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -43,14 +41,6 @@ Option | Default | Description
|
||||
|
||||
{% yields null cy.screenshot %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.screenshot %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.screenshot %}
|
||||
|
||||
# Examples
|
||||
|
||||
The screenshot will be stored in the `cypress/screenshots` folder by default.
|
||||
@@ -99,6 +89,20 @@ Taking a screenshot is an asynchronous action that takes around `100ms` to compl
|
||||
|
||||
For example - say a command we wrote times outs: {% url '`cy.get('#element')`' get %}. This causes your test to fail. Cypress then takes a screenshot when the test fails, but it's possible something in your application changed within the `100ms` timeframe. Hypothetically your app could render the element you were searching for. When this happens the screenshot may provide confusing results. It's unlikely, but theoretically possible.
|
||||
|
||||
# Notes
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.screenshot %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.screenshot %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.screenshot %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Take a screenshot with a specific filename**
|
||||
|
||||
@@ -53,18 +53,6 @@ Option | Default | Description
|
||||
|
||||
{% yields same_subject .select %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements selectability .select %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions actions .select %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .select %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Text Content
|
||||
@@ -131,6 +119,20 @@ cy.get('select').select(['apples', 'bananas'])
|
||||
cy.get('select').select(['456', '457'])
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements selectability .select %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions actions .select %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .select %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Select the option with the text "Homer Simpson"**
|
||||
|
||||
@@ -14,8 +14,6 @@ cy.setCookie(name, value, options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.setCookie()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -58,10 +56,6 @@ Option | Default | Description
|
||||
- `secure`
|
||||
- `expiry`
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
`cy.setCookie()` will wait up for the duration of {% url `responseTimeout` configuration#Timeouts %} for the automation server to process this command.
|
||||
|
||||
# Examples
|
||||
|
||||
## Set Value
|
||||
@@ -74,6 +68,20 @@ cy.setCookie('session_id', '189jd09sufh33aaiidhf99d09')
|
||||
cy.getCookie('session_id').should('have.property', 'value', '189jd09sufh33aaiidhf99d09')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.setCookie %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions once cy.setCookie %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.setCookie %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Set a cookie**
|
||||
|
||||
@@ -49,18 +49,6 @@ Option | Default | Description
|
||||
|
||||
{% yields changes_dom_subject .siblings %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .siblings %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .siblings %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .siblings %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Siblings
|
||||
@@ -90,6 +78,20 @@ cy.get('.active').siblings()
|
||||
cy.get('li').siblings('.active')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements existence .siblings %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions existence .siblings %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts existence .siblings %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Get the siblings of element with class `active`**
|
||||
|
||||
@@ -17,8 +17,6 @@ cy.spy(object, method)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.spy()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -41,14 +39,6 @@ Unlike most Cypress commands, `cy.spy()` is *synchronous* and returns a value (t
|
||||
|
||||
`cy.spy()` returns a [Sinon.js spy](http://sinonjs.org/docs/#spies). All [methods](http://sinonjs.org/docs/#spies-api) found on Sinon.JS spies are supported.
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.spy %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.spy %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Spy
|
||||
@@ -101,6 +91,20 @@ The main difference between `cy.spy()` and {% url `cy.stub()` stub %} is that `c
|
||||
|
||||
Cypress has also built-in {% url "sinon-chai" bundled-tools#Sinon-Chai %} support, so any {% url "assertions supported by `sinon-chai`" assertions#Sinon-Chai %} can be used without any configuration.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.spy %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.spy %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.spy %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Create a spy, alias it, and call it**
|
||||
|
||||
@@ -47,14 +47,6 @@ Unlike most Cypress commands, `cy.stub()` is *synchronous* and returns a value (
|
||||
|
||||
`cy.stub()` returns a {% url "Sinon.js stub" http://sinonjs.org/%}. All methods found on {% url "Sinon.js" http://sinonjs.org %} spies and stubs are supported.
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.stub %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.stub %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Stub
|
||||
@@ -147,6 +139,20 @@ The main difference between `cy.spy()` and {% url `cy.stub()` stub %} is that `c
|
||||
|
||||
Cypress has built-in {% url "sinon-as-promised" https://github.com/bendrucker/sinon-as-promised %} support, so the stubs returned by `cy.stub()` supports the `.resolves` and `.rejects` API provided by `sinon-as-promised`.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.stub %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.stub %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.stub %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Create a stub, alias it, and call it**
|
||||
|
||||
@@ -17,8 +17,6 @@ cy.tick(milliseconds)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.tick()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -45,14 +43,6 @@ The number of `milliseconds` to move the clock. Any timers within the affected r
|
||||
|
||||
You can also access the `clock` object via `this.clock` in a {% url `.then()` then %} callback.
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements tick cy.tick %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.tick %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Move time
|
||||
@@ -82,6 +72,20 @@ cy.get('#header').should('have.text', 'Hello, World')
|
||||
{% url "Check out our example recipe testing spying, stubbing and time" stubs-spies-and-clocks-recipe %}
|
||||
{% endnote %}
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements tick cy.tick %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.tick %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.tick %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Create a clock and tick it 1 second**
|
||||
|
||||
@@ -14,8 +14,6 @@ cy.title(options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.title()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -37,6 +35,18 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_subject cy.title 'yields the `document.title` property of the current page' %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Title
|
||||
|
||||
**Assert that the document's title is "My Awesome Application"**
|
||||
|
||||
```javascript
|
||||
cy.title().should('eq', 'My Awesome Application')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.title %}
|
||||
@@ -49,16 +59,6 @@ Option | Default | Description
|
||||
|
||||
{% timeouts assertions cy.title %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Title
|
||||
|
||||
**Assert that the document's title is "My Awesome Application"**
|
||||
|
||||
```javascript
|
||||
cy.title().should('eq', 'My Awesome Application')
|
||||
```
|
||||
|
||||
# Command Log
|
||||
|
||||
**Assert that the document's title includes 'New User'**
|
||||
|
||||
@@ -73,18 +73,6 @@ Option | Default | Description
|
||||
|
||||
{% yields same_subject .type %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements child_dom .type %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions actions .type %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .type %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Input/Textarea
|
||||
@@ -406,6 +394,20 @@ This strategy works well because when you are in development you are working in
|
||||
|
||||
In other words, you get the best of both worlds: simulated when its practical to do so, and native when it needs to run across browsers.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements child_dom .type %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions actions .type %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .type %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Type into the input**
|
||||
|
||||
@@ -18,8 +18,6 @@ Uncheck checkbox(es).
|
||||
|
||||
## Usage
|
||||
|
||||
`.uncheck()` requires being chained off another cy command that *yields* a DOM element of type `checkbox`.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -57,14 +55,6 @@ Option | Default | Description
|
||||
|
||||
{% yields same_subject .uncheck %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements checkability .uncheck %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .uncheck %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Uncheck
|
||||
@@ -97,6 +87,20 @@ cy.get('input[type="checkbox"]').uncheck(['ga'])
|
||||
cy.get('[type="checkbox"]').uncheck(['ga', 'ca'])
|
||||
```
|
||||
|
||||
# Notes
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements checkability .uncheck %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions actions .uncheck %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts actions .uncheck %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Uncheck the first checkbox**
|
||||
|
||||
@@ -41,18 +41,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_subject cy.url 'yields the current URL as a string' %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.url %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry cy.url %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.url %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Url
|
||||
@@ -92,6 +80,20 @@ But you may be wondering where the `url` property comes from. Per the `window.l
|
||||
|
||||
`cy.url()` exists because it's what most developers naturally assume would return them the full current URL. We almost never refer to the URL as an `href`.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.url %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry cy.url %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.url %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Assert that the url contains "#users/new"**
|
||||
|
||||
@@ -20,8 +20,6 @@ cy.viewport(preset, orientation, options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.viewport()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -72,14 +70,6 @@ Option | Default | Description
|
||||
|
||||
{% yields null cy.viewport %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.viewport %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.viewport %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Width, Height
|
||||
@@ -176,6 +166,20 @@ Scaling the app should not affect any calculations or behavior of your applicati
|
||||
|
||||
The upsides to this are that tests should consistently pass or fail regardless of a developers' screen size. Tests will also consistently run in `CI` because all of the viewports will be the same no matter what machine Cypress runs on.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.viewport %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions none cy.viewport %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts none cy.viewport %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Change viewport size to test responsive nav**
|
||||
|
||||
@@ -45,18 +45,6 @@ You can also set all `cy.visit()` commands' `pageLoadTimeout` and `baseUrl` glob
|
||||
|
||||
{% yields sets_subject cy.visit 'yields the `window` object after the page finishes loading' %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements page cy.visit %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions wait cy.visit %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts page cy.visit %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Visit
|
||||
@@ -195,6 +183,20 @@ cy.visit('http://localhost:8000/#/app')
|
||||
|
||||
Cypress will automatically apply the server and routes to the very next `cy.visit()` and does so immediately before any of your application code runs.
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements page cy.visit %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions wait cy.visit %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts page cy.visit %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Visit example application in a `beforeEach`**
|
||||
@@ -213,7 +215,6 @@ When clicking on `visit` within the command log, the console outputs the followi
|
||||
|
||||

|
||||
|
||||
|
||||
# See also
|
||||
|
||||
- {% url `cy.go()` go %}
|
||||
|
||||
@@ -14,8 +14,6 @@ cy.window(options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.window()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -37,14 +35,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_subject cy.window 'yields the `window` object' %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.window %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.window %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Window
|
||||
@@ -67,6 +57,20 @@ cy.window().then(function(win){
|
||||
cy.window({ timeout: 10000 }).should('have.property', 'foo')
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.window %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry cy.window %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.window %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Get the window**
|
||||
|
||||
@@ -13,8 +13,6 @@ Scopes all subsequent cy commands to within this element. Useful when working wi
|
||||
|
||||
## Usage
|
||||
|
||||
`.within()` requires being chained off another cy command that *yields* a DOM element.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
|
||||
@@ -14,8 +14,6 @@ cy.wrap(subject, options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.wrap()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -41,14 +39,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_subject cy.wrap 'yields the object it was called with' %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.wrap %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.wrap %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Wrap
|
||||
@@ -63,6 +53,20 @@ var getName = function() {
|
||||
cy.wrap({name: getName}).invoke('name').should('eq', 'Jane Lane') // true
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements parent cy.wrap %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions retry cy.wrap %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts assertions cy.wrap %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Make assertions about object**
|
||||
|
||||
@@ -16,8 +16,6 @@ cy.writeFile(filePath, contents, encoding, options)
|
||||
|
||||
## Usage
|
||||
|
||||
`cy.writeFile()` cannot be chained off any other cy commands, so should be chained off of `cy` for clarity.
|
||||
|
||||
**{% fa fa-check-circle green %} Correct Usage**
|
||||
|
||||
```javascript
|
||||
@@ -62,14 +60,6 @@ Option | Default | Description
|
||||
|
||||
{% yields sets_subject cy.writeFile 'yields the contents written to the file' %}
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements write_file cy.writeFile %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.writeFile %}
|
||||
|
||||
# Examples
|
||||
|
||||
## Text
|
||||
@@ -141,6 +131,20 @@ cy.writeFile('path/to/ascii.txt', 'Hello World', 'ascii'))
|
||||
Hello World
|
||||
```
|
||||
|
||||
# Rules
|
||||
|
||||
## Requirements {% helper_icon requirements %}
|
||||
|
||||
{% requirements write_file cy.writeFile %}
|
||||
|
||||
## Assertions {% helper_icon assertions %}
|
||||
|
||||
{% assertions once cy.writeFile %}
|
||||
|
||||
## Timeouts {% helper_icon timeout %}
|
||||
|
||||
{% timeouts automation cy.writeFile %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Write an array to a file**
|
||||
|
||||
@@ -11,7 +11,7 @@ comments: false
|
||||
|
||||
- **{% url 'Cypress API:' cypress-commands %}** Configure the behavior of how Cypress works internally. You can do things like access Environment Variables, change configuration, create custom commands, and more.
|
||||
|
||||
# Definitions
|
||||
# Rules
|
||||
|
||||
Each document attempts to cover the essentials of each method including:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user