Skip to content

feat: Loggable decorator for piped functions

Choose a tag to compare

@NicholasBoll NicholasBoll released this 02 May 16:25
· 30 commits to master since this release

loggable attaches additional metadata to helper functions for the .pipe Command. This includes ensuring the display name of a function regardless of the function being anonymous and also attaches parameters passed.

Example:

const getProp = loggable('getProp', prop => obj => obj[prop]
cy.wrap({ foo: 'bar'  })
  .pipe(getProp('foo'))
  .should('equal', 'bar')

This will show the following in the the Cypress Command Log:

WRAP      {foo: bar}
- PIPE    getProp("foo")
- ASSERT  expected bar to equal bar

Without using loggable, the PIPE line would not include arguments passed to getProp:

- PIPE   getProp

Fixes #16