Cypress: Allow formatting cy.log() text

Created on 12 Jul 2018  路  10Comments  路  Source: cypress-io/cypress

Current behavior:

cy.log() prints grey text to the left column:
screen shot 2018-07-12 at 10 48 26

Desired behavior:

cy.log() takes an option for formatting, e.g. color, bold:

cy.log('Given I am logged in', { color: 'blue' })

screen shot 2018-07-12 at 10 49 49

Steps to reproduce:

N/A

Versions

3.x

pkdriver ready for work feature

Most helpful comment

You can use markdown in the cy.log message and it will be formatted. It looks like we don't have this documented, so I've created an issue.

While you can't specify a color for the text, if you want blue text at least, you can trick it by making the message a link :)

cy.log('normal')
cy.log('**bold**')
cy.log('_italic_')
cy.log('[blue](http://example.com)')

cy.log markdown example output

All 10 comments

maybe you can use this

console.log('%c Given I am logged in', 'color: blue;')

The driver code for the log command is located here: https://github.com/cypress-io/cypress/blob/develop/packages/driver/src/cy/commands/misc.coffee#L14

But the server and reporter packages would both need to be updated to understand how to interpret this and display this as a properly formatted color.

I would not expect this work to get in anytime soon, just by comparing the value added with the work required to implement, unless we do see a large amount of requests for this.

Fair enough! It's just a nice-to-have :smiley: thanks for your quick response, and thanks for the great product!

You can use markdown in the cy.log message and it will be formatted. It looks like we don't have this documented, so I've created an issue.

While you can't specify a color for the text, if you want blue text at least, you can trick it by making the message a link :)

cy.log('normal')
cy.log('**bold**')
cy.log('_italic_')
cy.log('[blue](http://example.com)')

cy.log markdown example output

That's pretty neat - thanks!

It would be great to have similar functionality in the describe code.

I just wanted to apply color other than the Bule and not to link. I just wanted to apply in normal text. Please do advice.

Yes would be so great can change the text and background color

bump

I sometimes work around the problem of quickly finding certain lines by adding 馃崌emojis to the start of certain 馃攽messages to make them stand out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drewbrend picture drewbrend  路  85Comments

jennifer-shehane picture jennifer-shehane  路  87Comments

brian-mann picture brian-mann  路  101Comments

HugoGiraudel picture HugoGiraudel  路  97Comments

bahmutov picture bahmutov  路  69Comments