cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.87k stars 3.18k forks source link

Cypress & Serenity-js integration #1389

Open Baasie opened 6 years ago

Baasie commented 6 years ago

Desired behavior:

As discussed yesterday with @bahmutov @RandallKent and Jan Molak of Serenity-js. I want to see if we are able to integrate cypress with serenity. This will be a place to discuss this and review it.

why?

Serenity-js can be handy in multiple ways:

The challenges:

Test code:

see repo *** Disclaimer, this is POC, be faced that your Clean Code senses will go off. But it works as a simple example :)

brian-mann commented 6 years ago

A few notes:

It's not clear why you need to return promises - or why you need to wrap Cypress's command interface. Because Cypress manages the queue of commands in a global singleton - it's not needed to move these back to a traditional promise interface.

As long as Serenity-js calls cypress commands, everything will "just work" without needing to do anything.

Really as long as you translate everything into fundamental cypress commands you can layer anything on top of this that you want. Serenity-JS looks like another "page object pattern" and I'm not clear if or what it does differently than that.

Baasie commented 6 years ago

As far as I know, when I created this setup, it did not work that way. What I encountered, but I can be wrong, is that mocha required a Cypress promise to return to complete? That is why I am wrapping the serenity promise back to a cypress promise in the end.

jennifer-shehane commented 5 years ago

Hi, it's been a few months since this issue has had comments. Any updates?

michaelw85 commented 5 years ago

@Baasie I'm interested in using Serenity with Cypress and stumbled upon this post. I've looked at your POC and than started implementing my own following the serenity docs and I'm not running into any issues with the promises. The conversion you are doing in your poc does not seem to be required, maybe I'm overlooking something but my interactions are returning PromiseLike<void> and I'm using Cypress.Chainable in my abilities. I haven't added any cy commands.

EDIT:

The promise return type becomes a bit annoying when doing assertions. You can work around this by using async/await or wrapping the assertions in a then callback. This is a bit annoying of course. I'm currently trying to overwrite some types for a clean(er) setup.

Edit 2:

I continued on my own project and now also ran into issues with promises. I though everything was working fine returned cypress chainable types and overwriting types but I had false positives. Assertions are skipped so I'm also forced to write anything within the questions and interaction layers to promises and await everything I do within a test. It's workable but less clean than plain cypress.

s2oBCN commented 5 years ago

Hi! How is the state of this proposal?

michaelw85 commented 5 years ago

@s2oBCN For my part I can tell you that I completely dropped the serenity-js library, took some of the interfaces and completely created my own setup which ended up being very simple. I removed all the logging related code. It mostly just becomes a set of interfaces and a rather small base class responsible for executing methods in order. I created some basic tests but havent started actively using it in a project yet.

samlucax commented 4 years ago

Hi, any updates?

kfrajtak commented 1 year ago

@s2oBCN can you, please, share an example of your code?