interactors icon indicating copy to clipboard operation
interactors copied to clipboard

There is no way to get a value from interactor by using `cy.do`

Open wKich opened this issue 4 years ago • 3 comments

Intreactors have ability to read values from filters by using read function:

await read(TextField('Username'), 'value')

Or by calling filters

await TextField('Username').value()

But if we try to use it in cypress:

cy
  .do(TextField('Username').value())
  .then(($value) => { /* $value is undefined */ })

We can't get value back and use it in our assertions.

wKich avatar Oct 28 '21 07:10 wKich

Couldn't you just do this?

cy
  .then(TextField('username').value())
  .then(username => { /* ... */})

cowboyd avatar Nov 03 '21 10:11 cowboyd

So there's no reason to use cy.do or cy.expect except to show a nice display name in cypress log? I thought the cy.do should be able to return value

wKich avatar Nov 08 '21 10:11 wKich

I suppose we could, but isn't the point of do to do something imperative? cy.do(TextField().value()) isn't performing an action, it's reading a value.

cowboyd avatar Nov 15 '21 08:11 cowboyd