This blog marks the beginning of a new series on our blog. Unlike our new X-perience series, which focuses on sharing our engineers' experience on specifics, the X-periment series will contain ideas, contrasting opinions, and discussions on other topics, where we aim to give a broader as opposed to in-depth overview.
So, without further ado, let us dive right in.
Integration testing is one of those topics where opinions often clash. What should we use? Selenium? A headless solution like PhantomJS? Something else entirely?
Just recently, our developers have had a discussion about that. It all started with the search for...
On the one hand, setting up a decent Selenium setup can be quite an endeavor. On the other, it is still a very powerful tool. While there certainly are alternatives, some stick with the "old-school" approach. Our very own Alexis Hevia recently needed end-to-end tests for an Express/React application, and he chose a combination of Selenium for browser interaction, Jasmine as the testing framework, and two more must-have pieces of the puzzle, namely Selenium-standalone, which takes care of preparing a Selenium server, and selenium-webdriver which allows you to use Javascript with Selenium.
If you are curious how this setup worked out, click here for Alexis Hevia's guide.
An alternative for those that consider Selenium, well, unattractive, Cypress is planning to carve its niche as a very fast, browser-integrated framework for frontend testing, which requires neither Selenium Web Driver nor PhantomJS. With seamless CI-support and being a complete replacement for other test runners, the only downside it seems to have is that it is not out yet — it is expected sometime in 2017. Some people may not be huge fans already, others' opinion, however, can be summed up in a simple quote:
If you can get an early access for cypress, use that and never look back.
If you want to see it in action, click here and enjoy.
Nightwatch is an end-to-end testing framework, that offers clean syntax and can control the Selenium server. However, it can also be used together with PhantomJS with the aid of GhostDriver.
According to their own website,
Ghost Driver is a pure JavaScript implementation of the WebDriver Wire Protocol for PhantomJS. It's a Remote WebDriver that uses PhantomJS as back-end.
Now, if you need a tool that will actually control your browser, this is not the best thing available, but if headless testing is all that is required, you may want to go for this, also because a neat thing Nightwatch offers is using the Mocha exports interface, so you can run both unit tests and e2e tests in one go.
For instructions on how to use it, click here.
This is it. A short overview of three competing setups favored by our developers. Which one do you prefer? Selenium? PhantomJS? Perhaps something entirely different? Let us know!