scottohara / loot

An implementation of some of the core MS Money features in Ruby on Rails
MIT License
4 stars 3 forks source link

Consider switching Protractor out for Cypress.io #131

Closed scottohara closed 4 years ago

scottohara commented 6 years ago

The Protractor e2e test suite, while currently valuable, is incomplete (e.g. doesn't have any specs for account management or reconciliation), slow, and can sometimes be flaky.

Cypress.io is a relatively new e2e testing tool that has a different philosophy to traditional Selenium/WebDriver based tools (that have a node process running your e2e specs, and send requests over the network to drive a browser).

Cypress is an Electron app that runs both your test code and app code in the same process, and your test code has full access to the same DOM that your app code does. It also support time travelling between browser commands, making it easier to develop & debug tests.

With a potential move away from AngularJS on the cards, we may wish to consider something like Cypress as a replacement for the existing Protractor suite.

scottohara commented 6 years ago

At ng-conf 2018, there was a Protractor session that mentioned the blue-harvest npm module; which includes something called "action helpers".

https://www.youtube.com/watch?v=6aPfHrSl0Qk&index=4&list=WL

These helpers replace the need for Page Objects, and instead make tests extremely readable by using text-based selectors, so the test steps read like what you would say if you were instructing a person, e.g.

await click('First name:');
await type('Scott');
await click('Surname:');
await type('OHara');
await click('Register');
await slow.rightOf('Register').see('Successfully registered!');

The same talk also noted that Selenium 4.0 will see the end of the Control Flow, and all WebDriver testing will move to async/await. So rather than your protractor tests 'queuing up' commands that only get run at the end of the it() block (making it difficult to debug); you will be able to set breakpoints at specific parts of your test and it all should just work like normal debugging.