mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-23 15:39:28 -05:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # docs/source/guides/getting-started/installing-cypress.md
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
exports['passes --browser option 1'] = [
|
||||
"--project",
|
||||
null,
|
||||
"--cli-version",
|
||||
"0.19.2",
|
||||
"--browser",
|
||||
"test browser"
|
||||
]
|
||||
|
||||
exports['removes --record option when using --browser 1'] = [
|
||||
"--project",
|
||||
null,
|
||||
"--cli-version",
|
||||
"0.19.2",
|
||||
"--browser",
|
||||
"test browser"
|
||||
]
|
||||
|
||||
exports['passes --record option 1'] = [
|
||||
"--project",
|
||||
null,
|
||||
"--record",
|
||||
"my record id",
|
||||
"--cli-version",
|
||||
"0.19.2"
|
||||
]
|
||||
|
||||
exports['does not remove --record option when using --browser 1'] = [
|
||||
"--project",
|
||||
null,
|
||||
"--record",
|
||||
"foo",
|
||||
"--cli-version",
|
||||
"0.19.2",
|
||||
"--browser",
|
||||
"test browser"
|
||||
]
|
||||
|
||||
+7
-1
@@ -1,11 +1,12 @@
|
||||
const _ = require('lodash')
|
||||
const commander = require('commander')
|
||||
const { oneLine } = require('common-tags')
|
||||
|
||||
const coerceFalse = (arg) => {
|
||||
return arg !== 'false'
|
||||
}
|
||||
|
||||
const parseOpts = (opts) => _.pick(opts, 'spec', 'reporter', 'reporterOptions', 'path', 'destination', 'port', 'env', 'cypressVersion', 'config', 'record', 'key')
|
||||
const parseOpts = (opts) => _.pick(opts, 'spec', 'reporter', 'reporterOptions', 'path', 'destination', 'port', 'env', 'cypressVersion', 'config', 'record', 'key', 'browser')
|
||||
|
||||
const descriptions = {
|
||||
record: 'records the run. sends test results, screenshots and videos to your Cypress Dashboard.',
|
||||
@@ -16,6 +17,10 @@ const descriptions = {
|
||||
port: 'runs Cypress on a specific port. overrides any value in cypress.json. defaults to "2020"',
|
||||
env: 'sets environment variables. separate multiple values with a comma. overrides any value in cypress.json or cypress.env.json',
|
||||
config: 'sets configuration values. separate multiple values with a comma. overrides any value in cypress.json.',
|
||||
browser: oneLine`
|
||||
runs Cypress in the browser with the given name.
|
||||
note: using an external browser will cancel video recording of tests.
|
||||
`,
|
||||
}
|
||||
|
||||
const text = (description) => {
|
||||
@@ -42,6 +47,7 @@ module.exports = {
|
||||
.option('-p, --port <port>', text('port'))
|
||||
.option('-e, --env <env>', text('env'))
|
||||
.option('-c, --config <config>', text('config'))
|
||||
.option('-b, --browser <browser name>', text('browser'))
|
||||
.action((opts) => require('./exec/run').start(parseOpts(opts)))
|
||||
|
||||
program
|
||||
|
||||
+11
-1
@@ -4,7 +4,7 @@ const downloadUtils = require('../download/utils')
|
||||
const spawn = require('./spawn')
|
||||
const pkg = require('../../package')
|
||||
|
||||
const run = (options) => () => {
|
||||
const processRunOptions = (options = {}) => {
|
||||
const args = ['--project', options.project]
|
||||
|
||||
//// if key is set use that - else attempt to find it by env var
|
||||
@@ -65,10 +65,20 @@ const run = (options) => () => {
|
||||
//// send in the CLI version
|
||||
args.push('--cli-version', pkg.version)
|
||||
|
||||
if (options.browser) {
|
||||
args.push('--browser', options.browser)
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
const run = (options) => () => {
|
||||
const args = processRunOptions(options)
|
||||
return spawn.start(args)
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
processRunOptions,
|
||||
start (options = {}) {
|
||||
_.defaults(options, {
|
||||
key: null,
|
||||
|
||||
@@ -2,6 +2,7 @@ const _ = require('lodash')
|
||||
const cp = require('child_process')
|
||||
const chalk = require('chalk')
|
||||
const Promise = require('bluebird')
|
||||
const debug = require('debug')('cypress:cli')
|
||||
|
||||
const downloadUtils = require('../download/utils')
|
||||
const xvfb = require('./xvfb')
|
||||
@@ -20,7 +21,12 @@ module.exports = {
|
||||
|
||||
const spawn = () => {
|
||||
return new Promise((resolve) => {
|
||||
const child = cp.spawn(downloadUtils.getPathToExecutable(), args, options)
|
||||
const cypressPath = downloadUtils.getPathToExecutable()
|
||||
debug('spawning Cypress %s', cypressPath)
|
||||
debug('args %j', args)
|
||||
debug('some of the options %j', _.pick(options, ['verify', 'detached']))
|
||||
|
||||
const child = cp.spawn(cypressPath, args, options)
|
||||
if (needsXvfb) {
|
||||
//// make sure we close down xvfb
|
||||
//// when our spawned process exits
|
||||
|
||||
@@ -7,12 +7,37 @@ const downloadUtils = require('../../lib/download/utils')
|
||||
const cli = require('../../lib/cli')
|
||||
const spawn = require('../../lib/exec/spawn')
|
||||
const run = require('../../lib/exec/run')
|
||||
const snapshot = require('snap-shot')
|
||||
|
||||
describe('exec run', function () {
|
||||
beforeEach(function () {
|
||||
this.sandbox.stub(process, 'exit')
|
||||
})
|
||||
|
||||
context('#processRunOptions', function () {
|
||||
it('passes --browser option', () => {
|
||||
const args = run.processRunOptions({
|
||||
browser: 'test browser',
|
||||
})
|
||||
snapshot(args)
|
||||
})
|
||||
|
||||
it('passes --record option', () => {
|
||||
const args = run.processRunOptions({
|
||||
record: 'my record id',
|
||||
})
|
||||
snapshot(args)
|
||||
})
|
||||
|
||||
it('does not remove --record option when using --browser', () => {
|
||||
const args = run.processRunOptions({
|
||||
record: 'foo',
|
||||
browser: 'test browser',
|
||||
})
|
||||
snapshot(args)
|
||||
})
|
||||
})
|
||||
|
||||
context('cli interface', function () {
|
||||
beforeEach(function () {
|
||||
this.sandbox.stub(run, 'start')
|
||||
|
||||
@@ -25,6 +25,17 @@ public_dir: public
|
||||
i18n_dir: :lang
|
||||
skip_render:
|
||||
|
||||
# Generate alias pages for redirecting to posts, pages or URL
|
||||
# You must run `npm run build` for changes to take effect
|
||||
# https://github.com/hexojs/hexo-generator-alias
|
||||
alias:
|
||||
index.html: guides/getting-started/why-cypress.html
|
||||
guides/index.html: guides/getting-started/why-cypress.html
|
||||
api/index.html: api/welcome/api.html
|
||||
examples/index.html: examples/recipes/unit-testing.html
|
||||
# can also do outside page links here
|
||||
# plugins/index.html: https://github.com/cypress/cypress/wiki/Plugins
|
||||
|
||||
# Include/Exclude Files/Folders
|
||||
include:
|
||||
- api/utilities/** ## This ensures that our '_.md' file is included
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
"hexo": "github:cypress-io/hexo#d709e91b9a014d01215bcebc7299ea3e2ad9153d",
|
||||
"hexo-algoliasearch": "0.2.1",
|
||||
"hexo-filter-cleanup": "1.0.7",
|
||||
"hexo-generator-alias": "0.1.3",
|
||||
"hexo-generator-seo-friendly-sitemap": "0.0.20",
|
||||
"hexo-prism-plugin": "2.0.2",
|
||||
"hexo-renderer-marked": "0.3.0",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
'use strict'
|
||||
const path = require('path')
|
||||
const util = require('hexo-util')
|
||||
const urlGenerator = require('../lib/url_generator')
|
||||
|
||||
@@ -107,3 +108,9 @@ hexo.extend.tag.register('url', function (args) {
|
||||
})
|
||||
|
||||
}, { async: true })
|
||||
|
||||
hexo.extend.tag.register('partial', (fileName) => {
|
||||
const pathToFile = path.resolve('source', '_partial', `${fileName}.md`)
|
||||
|
||||
return hexo.render.render({ path: pathToFile, engine: 'markdown' })
|
||||
}, { async: true })
|
||||
|
||||
@@ -145,3 +145,17 @@ api:
|
||||
dom: dom.html
|
||||
env: env.html
|
||||
cypress-server: server.html
|
||||
|
||||
examples:
|
||||
recipes:
|
||||
unit-testing: unit-testing.html
|
||||
logging-in: logging-in.html
|
||||
testing-the-dom: testing-the-dom.html
|
||||
working-with-the-backend: working-with-the-backend.html
|
||||
spies-stubs-and-clocks: spies-stubs-and-clocks.html
|
||||
extending-cypress: extending-cypress.html
|
||||
applications:
|
||||
kitchen-sink: kitchen-sink.html
|
||||
todo-mvc: todo-mvc.html
|
||||
pie-chopper: pie-chopper.html
|
||||
phonecat: phonecat.html
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
**What's the difference between `.then()` and `.should()`/`.and()`?**
|
||||
|
||||
Using `.then()` simply allows you to use the yielded subject in a callback function and should be used when you need to manipulate some values or do some actions.
|
||||
|
||||
When using a callback function with `.should()` or `.and()`, on the other hand, there is special logic to rerun the callback function until no assertions throw within it. You should be careful of side affects in a `.should()` or `.and()` callback function that you would not want performed multiple times.
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: scrollIntoView
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Scroll an element into view.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: scrollTo
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Scroll to a specific position.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: trigger
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Trigger an event on a DOM element.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: and
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Make an assertion.
|
||||
@@ -43,7 +43,7 @@ cy.and('eq', '42') // Errors, cannot be chained off 'cy'
|
||||
|
||||
**{% fa fa-angle-right %} chainers** ***(String)***
|
||||
|
||||
Chainers that come from [Chai](https://on.cypress.io/guides/bundled-tools#chai) or [Chai-jQuery](https://on.cypress.io/guides/bundled-tools#chai-jquery)
|
||||
Chainers that come from {% url 'Chai' bundled-tools#Chai %} or {% url 'Chai-jQuery' bundled-tools#Chai-jQuery %}
|
||||
|
||||
**{% fa fa-angle-right %} value** ***(String)***
|
||||
|
||||
@@ -78,13 +78,24 @@ cy
|
||||
|
||||
## Timeout
|
||||
|
||||
`.and()` will continue to retry the assertion to the duration of the previous cy commands `timeout` or the {% url `defaultCommandTimeout` configuration#Timeouts %}.
|
||||
`.and()` will continue to retry until none of the assertions throw for the duration of the previous cy commands `timeout`.
|
||||
|
||||
```javascript
|
||||
cy.get('input', {timeout: 10000}).should('have.value', '10').and('have.class', 'error')
|
||||
↲
|
||||
// timeout here will be passed down to the '.and()'
|
||||
// and it will retry for up to 10 secs
|
||||
// timeout here will be passed down to the '.and()'
|
||||
// and it will retry for up to 10 secs
|
||||
```
|
||||
|
||||
```javascript
|
||||
cy.get('input', {timeout: 10000}).should('have.value', 'US').and(function($input)){
|
||||
↲
|
||||
// timeout here will be passed down to the '.and()'
|
||||
// unless an assertion throws earlier,
|
||||
// ALL of the assertions will retry for up to 10 secs
|
||||
expect($input).to.not.be('disabled')
|
||||
expect($input).to.not.have.class('error')
|
||||
})
|
||||
```
|
||||
|
||||
# Examples
|
||||
@@ -207,10 +218,12 @@ expect({foo: 'bar'}).to.have.property('foo').and.eq('bar')
|
||||
|
||||
**How do I know which assertions change the subject and which keep it the same?**
|
||||
|
||||
The chainers that come from [Chai](https://on.cypress.io/guides/bundled-tools#chai) or [Chai-jQuery](https://on.cypress.io/guides/bundled-tools#chai-jquery) will always document what they return.
|
||||
The chainers that come from {% url 'Chai' bundled-tools#Chai %} or {% url 'Chai-jQuery' bundled-tools#Chai-jQuery %} will always document what they return.
|
||||
|
||||
You can [read more about debugging assertions](https://on.cypress.io/guides/making-assertions#debugging-assertions) here.
|
||||
|
||||
{% partial then_should_difference %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Chain assertions on the same subject**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: as
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Assign an alias for later use. Reference the alias later within a {% url `cy.get()` get %} or {% url `cy.wait()` wait %} command with a `@` prefix.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: blur
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Make a focused DOM element blur.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: check
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Check checkbox(es) or radio(s).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: children
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the children of each DOM element within a set of DOM elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: clear
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Clear the value of an `input` or `textarea`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: clearCookie
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Clear a browser cookie.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: clearCookies
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Clear all browser cookies.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: clearLocalStorage
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Clear all data in local storage.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: click
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Click a DOM element.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: clock
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
`cy.clock()` overrides native global functions related to time allowing them to be controlled synchronously via {% url `cy.tick()` tick %} or the yielded `clock` object. This includes controlling:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: closest
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the first DOM element that matches the selector (whether it be itself or one of it's ancestors).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: contains
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the DOM element containing the text. DOM elements can contain *more* than the desired text and still match. Additionally, Cypress [prefers some DOM elements](#Notes) over the deepest element found.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: dblclick
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Double-click a DOM element.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: debug
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Set a `debugger` and log what the previous command yields.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: document
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the document.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: each
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Iterate through an array like structure (arrays or objects with a `length` property).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: end
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
End a chain of commands.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: eq
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get A DOM element at a specific index in an array of elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: exec
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Execute a system command.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: filter
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the DOM elements that match a specific selector.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: find
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the descendent DOM elements of a specific selector.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: first
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the first DOM element within a set of DOM elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: fixture
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Load a fixed set of data located in a file.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: focus
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Focus on a DOM element.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: focused
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the DOM element that is currently focused.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: get
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get one or more DOM elements by selector or [alias](https://on.cypress.io/guides/using-aliases).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: getCookie
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get a browser cookie by it's name.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: getCookies
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all of the browser cookies.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: go
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Navigate back or forward to the previous or next URL in the browser's history.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: hash
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the current URL hash.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: hover
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
{% note danger %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: invoke
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Invoke a function on the previously yielded subject.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: its
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get a property on the previously yielded subject.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: last
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the last DOM element within a set of DOM elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: location
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the remote `window.location` as an object.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: log
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Print a message to the Cypress Command Log.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: next
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the immediately following sibling of each DOM element within a set of DOM elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: nextAll
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all following siblings of each DOM element in a set of matched DOM elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: nextUntil
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all following siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: not
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Filter DOM element(s) from a set of DOM elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: parent
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the parent DOM element of a set of DOM elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: parents
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the parent DOM elements of a set of DOM elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: parentsUntil
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all ancestors of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: pause
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Stop `cy` commands from running and allow interaction with the application under test. You can then "resume" running all commands or choose to step through the "next" commands from the Command Log.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: prev
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the immediately preceding sibling of each element in a set of the elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: prevAll
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all previous siblings of each DOM element in a set of matched DOM elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: prevUntil
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get all previous siblings of each DOM element in a set of matched DOM elements up to, but not including, the element provided.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: readFile
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Read a file and yield its contents.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: reload
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Reload the page.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: request
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Make an HTTP request.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: root
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the root element.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: route
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Use `cy.route` to manage the behavior of network requests.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: screenshot
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Take a screenshot of the application under test and the Cypress Command Log.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: select
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Select an `<option>` within a `<select>` DOM element.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: server
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Start a server to begin routing responses to `cy.route()` and `cy.request()`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: setCookie
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Set a browser cookie.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: should
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Make an assertion.
|
||||
@@ -45,7 +45,7 @@ cy.should('eq', '42') // Errors, cannot be chained off 'cy'
|
||||
|
||||
**{% fa fa-angle-right %} chainers** ***(String)***
|
||||
|
||||
Chainers that come from [Chai](https://on.cypress.io/guides/bundled-tools#chai) or [Chai-jQuery](https://on.cypress.io/guides/bundled-tools#chai-jquery)
|
||||
Chainers that come from {% url 'Chai' bundled-tools#Chai %} or {% url 'Chai-jQuery' bundled-tools#Chai-jQuery %}
|
||||
|
||||
**{% fa fa-angle-right %} value** ***(String)***
|
||||
|
||||
@@ -68,6 +68,7 @@ cy
|
||||
.get('nav') // yields <nav>
|
||||
.should('be.visible') // yields <nav>
|
||||
```
|
||||
|
||||
Although some chainers change what is yielded. In the example below, the second `.should()` yields the String 'sans-serif' because the chainer `have.css, 'font-family'` yields a string.
|
||||
|
||||
```javascript
|
||||
@@ -79,13 +80,25 @@ cy
|
||||
|
||||
## Timeout
|
||||
|
||||
`.should()` will continue to retry the assertion to the duration of the previous cy commands `timeout` or the {% url `defaultCommandTimeout` configuration#Timeouts %}.
|
||||
`.should()` will continue to retry until none of the assertions throw for the duration of the previous cy commands `timeout`.
|
||||
|
||||
```javascript
|
||||
cy.get('input', {timeout: 10000}).should('have.value', '10')
|
||||
↲
|
||||
// timeout here will be passed down to the '.should()'
|
||||
// and it will retry for up to 10 secs
|
||||
// timeout here will be passed down to the '.should()'
|
||||
// and it will retry for up to 10 secs
|
||||
```
|
||||
|
||||
```javascript
|
||||
cy.get('input', {timeout: 10000}).should(function($input)){
|
||||
↲
|
||||
// timeout here will be passed down to the '.should()'
|
||||
// unless an assertion throws earlier,
|
||||
// ALL of the assertions will retry for up to 10 secs
|
||||
expect($input).to.not.be('disabled')
|
||||
expect($input).to.not.have.class('error')
|
||||
expect($input).to.have.value('US')
|
||||
})
|
||||
```
|
||||
|
||||
# Examples
|
||||
@@ -114,10 +127,10 @@ cy.get('option:first').should('be.selected').then(function($option)){
|
||||
cy.get('form').should('have.class', 'form-horizontal')
|
||||
```
|
||||
|
||||
**Assert the value is not 'foo'**
|
||||
**Assert the value is not 'Jane'**
|
||||
|
||||
```javascript
|
||||
cy.get('input').should('not.have.value', 'foo')
|
||||
cy.get('input').should('not.have.value', 'Jane')
|
||||
```
|
||||
|
||||
**The current subject is yielded**
|
||||
@@ -141,7 +154,7 @@ cy.get('#header a').should('have.attr', 'href', '/users')
|
||||
|
||||
**Verify length, content, and classes from multiple `<p>`**
|
||||
|
||||
Passing a function to `.should()` enables you to assert on the yielded subject. This gives you the opportunity to *massage* what you'd like to assert on.
|
||||
Passing a function to `.should()` enables you to make multiple assertions on the yielded subject. This also gives you the opportunity to *massage* what you'd like to assert on.
|
||||
|
||||
Just be sure *not* to include any code that has side effects in your callback function. The callback function will be retried over and over again until no assertions within it throw.
|
||||
|
||||
@@ -191,16 +204,16 @@ Any errors raised by failed assertions will immediately bubble up and cause the
|
||||
```
|
||||
|
||||
```javascript
|
||||
cy.get("#todos li").should(function($lis){
|
||||
cy.get('#todos li').should(function($lis){
|
||||
expect($lis).to.have.length(3)
|
||||
expect($lis.eq(0)).to.contain("Walk the dog")
|
||||
expect($lis.eq(1)).to.contain("Feed the cat")
|
||||
expect($lis.eq(2)).to.contain("Write JavaScript")
|
||||
expect($lis.eq(0)).to.contain('Walk the dog')
|
||||
expect($lis.eq(1)).to.contain('Feed the cat')
|
||||
expect($lis.eq(2)).to.contain('Write JavaScript')
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
**Using a callback function will not change the subject**
|
||||
**Using a callback function will not change what is yielded**
|
||||
|
||||
Whatever is returned in the function is ignored. Cypress always forces the command to yield the value from the previous cy command's yield (which in the example below is `<button>`)
|
||||
|
||||
@@ -250,16 +263,16 @@ cy.get('button').click()
|
||||
.and('not.have.class', 'inactive')
|
||||
```
|
||||
|
||||
You can [read more about how Cypress resolves your assertions](https://on.cypress.io/guides/making-assertions#resolving-assertions) here.
|
||||
|
||||
# Notes
|
||||
|
||||
**How do I know which assertions change the subject and which keep it the same?**
|
||||
|
||||
The chainers that come from [Chai](https://on.cypress.io/guides/bundled-tools#chai) or [Chai-jQuery](https://on.cypress.io/guides/bundled-tools#chai-jquery) will always document what they return.
|
||||
The chainers that come from {% url 'Chai' bundled-tools#Chai %} or {% url 'Chai-jQuery' bundled-tools#Chai-jQuery %} will always document what they return.
|
||||
|
||||
You can [read more about debugging assertions](https://on.cypress.io/guides/making-assertions#debugging-assertions) here.
|
||||
|
||||
{% partial then_should_difference %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**Assert that there should be 8 children in a nav**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: siblings
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get sibling DOM elements.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: spread
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Expand an array into multiple arguments.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: spy
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Wrap a method in a spy in order to record calls to and arguments of the function.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: stub
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Replace a function, record its usage and control its behavior.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: submit
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Submit a form.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: then
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Yield the previously yielded subject as the first argument of a function.
|
||||
@@ -67,10 +67,10 @@ cy.get('form').find('input').then(function($input){
|
||||
|
||||
```javascript
|
||||
cy.then(function(){
|
||||
return {foo: 'bar'}
|
||||
return {id: 123}
|
||||
}).then(function(obj){
|
||||
// subject is now the obj {foo: 'bar'}
|
||||
expect(obj).to.deep.eq({foo: 'bar'}) // true
|
||||
// subject is now the obj {id: 123}
|
||||
obj.id === 123 // true
|
||||
})
|
||||
```
|
||||
|
||||
@@ -85,7 +85,7 @@ cy
|
||||
}).find('input').then(function($input){
|
||||
// we have our $input element here since
|
||||
// our form element was yielded and we called
|
||||
// .find("input") on it
|
||||
// .find('input') on it
|
||||
})
|
||||
```
|
||||
|
||||
@@ -129,9 +129,18 @@ cy.get('button').click().then(function($button){
|
||||
})
|
||||
```
|
||||
|
||||
# Notes
|
||||
|
||||
{% partial then_should_difference %}
|
||||
|
||||
# Command Log
|
||||
|
||||
**`cy.then()` does *not* log in the command log**
|
||||
|
||||
# See also
|
||||
|
||||
- {% url `.and()` and %}
|
||||
- {% url `.each()` each %}
|
||||
- {% url `.invoke()` invoke %}
|
||||
- [Issuing Commands](https://on.cypress.io/guides/issuing-commands)
|
||||
- {% url `.its()` its %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: tick
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Move time after overriding a native time function with {% url `cy.clock()` clock %}.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: title
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the title of the document.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: type
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Type into a DOM element.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: uncheck
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Uncheck checkbox(es).
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: url
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the current URL.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: viewport
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Control the size and orientation of the screen for your application.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: visit
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Visit a remote url.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: wait
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Wait for a number of milliseconds or wait for an aliased resource to resolve before moving on to the next command.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: window
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Get the global `window` object of the remote application that was visited in {% url `cy.visit()` visit %}.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: within
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Set the scope of the containing commands to the previously yielded subject and pass that as an argument to the callback function.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: wrap
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Yield the object passed into `.wrap()`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: writeFile
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Write to a file with the specified contents.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress commands
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Cypress comes with its own API for creating custom commands. In fact, the same public methods *you* have access to are the same ones we use to create all of the built in commands. In other words, there's nothing special or different about ours versus yours. You can customize every aspect of commands, not only their behavior, but also their display in the Command Log.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.config
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
`get` and `set` configuration options *in your tests*.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.Cookies
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
`Cookies.debug()`, `Cookies.preserveOnce()` and `Cookies.defaults()` allow you to do more than just get, set, or clear cookies.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.Dom
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
`Cypress.Dom.isHidden()` allows you to work with logic that determines whether an element is hidden.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.env
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
`get` and `set` environment variables *in your tests*.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.Server
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Permanently change the default options for all {% url `cy.server()` server %} instances
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.$
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Cypress automatically proxies [jQuery](https://jquery.com/) and exposes it as `Cypress.$`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress._
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Cypress automatically proxies [Underscore](http://underscorejs.org/) and exposes it as `Cypress._`. Call any valid Underscore method on `Cypress._`
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.Blob
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Cypress proxies a [`Blob Utilities`](https://github.com/nolanlawson/blob-util) library and exposes it as `Cypress.Blob`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.minimatch
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Cypress automatically proxies [`minimatch`](https://github.com/isaacs/minimatch) and exposes it as `Cypress.minimatch`.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Cypress.moment
|
||||
comments: true
|
||||
comments: false
|
||||
---
|
||||
|
||||
Cypress automatically proxies [`moment.js`](http://momentjs.com/) and exposes it as `Cypress.moment`.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user