How to interactively work with cypress $Chainer objects in the JS console?

Viewed 28

When running cypress e2e tests in browser I'd like to test and build up further cypress commands step by step. So I open the dev tools and enter a cypress command in the JS console, but it always returns a $Chainer object. How can I make something useful out of that?


res = cy.get('body')
>$Chainer {specWindow: Window, chainerId: 'ch-http://localhost:8080-200'}
// How can I access the dom element using res?

res = cy.get('body').should('exist')
>$Chainer {specWindow: Window, chainerId: 'ch-http://localhost:8080-201'}
// How can I see the result of should('exist')? 

res = cy.get('input[type=checkbox]')
>$Chainer {specWindow: Window, chainerId: 'ch-http://localhost:8080-202'}
// How to get the number of checkboxes from res?

This kind of cypress playground would be really useful. I tried Cypress.dom.unwrap, but it has no effect on the $Chainer object. If used as shown in the docs but in the console, the callback inside then() is never called:

cy.get('body').then(($el) => {
  // never called
  console.log($el)
  Cypress.dom.unwrap($el)
})

Can this be triggered somehow?

0 Answers
Related