Cypress run command without re-running test

Viewed 297

Just wondering, say I have a lengthy cypress test that has finished running. Is there a way to try out a new cypress command, say something like

cy.get('.tg-tag').should('have.css', 'background-color', 'rgb(0, 128, 0)')

Thanks much!

2 Answers

There is the cy.now() internal command that allows the user to run a cypress command via dev tools in the test runner. Gleb has a general example here and a more detailed example here. The Cypress docs has a small example here.

There are also a few discussion on cypress github found below with examples of usage:

You'll have to play around with your specific situation, but once your test has completed, open your dev tools and use the following format:

// cy.now(commandName, arguments…)

cy.now('visit', '/') // visit root
cy.now('contains', 'button', 'Sign in')

If you mean you want to use a kind of interactive mode for new/additional commands, there's the experimental Cypress Studio mode.

It's not free text, but you can add the expression you indicated, best described in the PR

enter image description here

Related