Cypress parallelization with the Orchestrator — part 1
Edit: Here is the 2nd part
Hello again, My company decided to build our own UI components and I joined the UI development team as a testing engineer. We decided to apply the snapshot testing over our UI components. so I have been using Cypress and lots of plugins to do it😉
It was okay to execute the test cases in series at the beginning of the project but once we had lots of tests that consume a lot of time in the testing stage ☹️ and we figured out that we need an urgent solution.
Before that, I have been using Selenium and I know the ideal solution to this problem is, “Execute the test case in parallel”. It is simple enough 🤓, No?
So I created a task to figure out the suitable way to execute the cypress specs in parallel and then I figured out the issues 🥴🥴. There is no way to run Cypress in parallel without using the Cypress-dashboard which is pretty much expensive 😱😱 As an example, We almost consumed their premium-plan in a week 🤣🤣 and there are almost no other benefits from using their dashboard. They don’t even execute the test cases in their infrastructure but, they asked to get access to our CI to be able to fire the test cases in our infrastructure. One of my colleagues used to say that “Whoever invented Cypress, He did that to make himself rich 🤣”. The second issue was that we had a security concern issue about that, as there is a connection between our Jenkins cluster and the Cypress dashboard that we don’t know much about it.
So, I tried to find another solution and then I found the Sorry-Cypres project. I liked the idea but I hated that I have to create many Jenkins parallel steps and deploy a sorry-cypress dashboard too 😓😓.
At this time I decided to build my own solution for this issue. I only need a tool that has the ability to split the cypress specs across different processes and generate a report at the end of the execution. That is it!.
I coded the Orchestrator 💪to solve the parallelization problem ✌️I took into my consideration that, this tool should be simple and should introduce a particular solution to this issue.
Let’s demonstrate the mechanism of the Orchestrator and letter on I’m gonna write more technical details about it.
First of all, The Orchestrator will be your execution command and you don't have to create multi-stages in Jenkings nor muli jobs in Github. All you have to do is configuring the Orchestrator file and fire the following command
orchestrator --config orchestrator-demo-config.json
That is it 👌 but let's demonstrate what’s going on underneath. The orchestrator gonna read all your cypress specs and your testing docker-compose file, then It will fire the AUT container and gonna fire n Cypress containers (n is a configurable number) for each browser (Yes, it takes into consideration the cross-browsing testing 🤝) , after that It will split the specs across all those containers and at the end, It will collect the JSON mocha-awsome reports and generates one HTML report for all specs after that It will turn all containers down and clean the environment 🦹♂️.
Here is the 2nd part