Spec-Zone.ru › Cypress

log

Print a message to the Cypress Command Log.

Syntax

cy.log(message)
cy.log(message, args...)

Usage

Correct Usage

cy.log('created new user')

Arguments

message (String)

Message to be printed to Cypress Command Log. Accepts a Markdown formatted message.

args...

Additional arguments to be printed to the Cypress Command Log. There is no limit to the number of arguments.

Yields

  • cy.log() yields null .
  • cy.log() cannot be chained further.

Examples

Message

Print a message to the Command Log.

cy.click('Login')
cy.url().should('not.include', 'login')
cy.log('Login successful')

Args

Print a message with arguments to the Command Log.

cy.log('events triggered', events)

Rules

Requirements

  • cy.log() requires being chained off of cy .

Assertions

  • cy.log() cannot have any assertions chained.

Timeouts

  • cy.log() cannot time out.

Command Log

Print messages with arguments to the Command Log.

cy.log('log out any message we want here')
cy.log('another message', ['one', 'two', 'three'])

The commands above will display in the Command Log as:

Command Log log

When clicking on log within the command log, the console outputs the following:

Console Log log

See also

  • cy.exec()
  • Cypress.log
  • cy.task()

© 2017 Cypress.io
Licensed under the MIT License.
https://docs.cypress.io/api/commands/log

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API