Add steps to your tests
npm install cypress-plugin-steps
A small Cypress helper that adds your test steps to the timeline and error logs.
cy.log() to cy.step() commandsInstall this package:
``bash`
npm i cypress-plugin-stepsor
yarn add cypress-plugin-steps
Import the plugin into your cypress/support/e2e.js file:`js`
import 'cypress-plugin-steps'
// or
require('cypress-plugin-steps')tsconfig.json$3
In most cases, types work just by installing plugin, but you can add the types to your `json`
{
"types": ["cypress-plugin-steps"]
}cy.step()
This will add types for , cy.section(), and cy.todo() command.
and cy.section() See the details below$3
This works similarly to cy.log() command, but in addition, will add numbering to your tests:`ts
it('numbers test steps', () => { cy.step('open a page')
cy.visit('cypress/index.html')
cy.step('find all primary colors')
cy.get('.primary')
cy.step('select blue')
cy.get('.blue')
});
`$3
This command is meant to note a part of the test missing implementation.
`js
cy.todo('Use better test selectors')
`$3
If your test fails, your scenario will be added to the error message. This way your scenario will be visible right on the error screenshot that Cypress does automatically:You can also see the scenario in terminal:
!error in terminal
$3
Works similarly to cy.step() but will be more prominent in Cypress runner (adding '---' to the log message) and will reset counter. This way you can divide your test into multiple secions.$3
You can find and replace all your
cy.log() commands by matching the word log with following regex:
`
(?:cy\s)?log\s
``
...powered by coffee and love ❤️ Filip Hric