Files
cypress/docs/source/api/commands/log.md
2017-06-09 14:04:20 -04:00

1.6 KiB

title, comments
title comments
log true

Print a message to the Cypress Command Log.

Syntax

cy.log(message)
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 %} Valid Usage

cy.log('created new user')    

Arguments

{% fa fa-angle-right %} message (String)

Message to be printed to Cypress Command Log.

{% fa fa-angle-right %} 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.

Timeout

Examples

Message

Print a message to the Command Log.

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

Arguments

Print a message with arguments to the Command Log.

cy.log('events triggered', events)

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 with cy.log

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

console display of cy.log

See also

  • {% url cy.exec() exec %}