The secret passages – headless testing
To quickly check the code in a browser, we can perform headless testing, which would not include the UI. It performs all the functions needed, but will not show the graphic view, which would result in faster performance and execution of the tests.
The caveat of using such a system is that we are not fully experiencing the same as the users would, so we may miss issues and the ones found would be harder to debug:
- With Cypress, use
./node_modules/.bin/cypress run
instead ofopen
, as we did in the preceding examples - With Selenium, set the options to headless as part of the particular driver of your browser (check the documentation for each)
There are other alternatives to automating with a headless browser; please check if your current framework has one before you decide on another one. Also, if you decide you need a different framework for headless testing, make sure you run benchmarks before arguing which framework...