4

In my work I use Selenium(Java) to automated test. Now web application will be rewritten to React, and there's my question:

Automating react application using Selenium under Java is good choice? Do You have any experience with this technologies together? such tests would be stable? Or maybe better way would be to write tests in JavaScript-based testing library like cypress.io ? What's the difference between this two automating library in practice?

2 Answers 2

1

A brief comparison

Selenium is very mature and widely used and as such it supports development in multiple languages including Java and has a active community Selenium Slack. As discussed here, Cypress probably has limited browser support. For the list of issues go to their respective Github projects cypress and selenium. Other considerations to take into account are the test runner, test reporting and development tools available to you. Cypress certainly appears fast as it's executing the tests in the browser as you write them, however you will probably be more limited in terms of test runner and reporting tools. React with cypress indicates it will work however it's not clear if multiple browser support is there yet. React with Selenium supports Firefox and Chrome from what I can tell.

Stability of tests

In terms of stability, I always refer to the Test pyramid where you see how much resources you should be spending on each level of tests. UI Tests are notoriously unstable as you are asking the computer to check if something "looks good". Jest snapshots pass the issue on to the committer to confirm the rendering "looks good" so that may be a better option for styling.

Time box experiment Experiment with both if you have time.

Note: I've only developed against Selenium.

1

Selenium aims to simulate browser activity - to check enviorments are properly setup and external services are in-place. It is end-to-end checking: From the UI, down to the DB and back, touch every integration along the way.

If you want to test your React app, you should largely rely on React testing toolset: Enzyme, Jest, React Testing Library, etc. They are aimed to test Frontend code, leveraging React enviorment components.

Frontend checking != End-to-end checking

Using End-to-end to check frontend is as absurd to try to replace unit checks with Selenium.

I have written about this difference and the frontend tools for the Ember.js world, but the idea very similar: http://thatsabug.com/2018/08/08/testing_ember_application_first_steps.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.