When you think of headless web application testing, you probably think about PhantomJS. PhantomJS has support for libraries a huge range of testing libraries, and being based on WebKit means that PhantomJS also has good support for the latest web standards, which has made PhantomJS a very popular choice for headless web app testing.
Recently, though, mainstream browsers like Chrome and Firefox have added native support for headless browsing. And we've been possible to run tests in headless Linux environments using tools like xvfb for quite some time.
So what does this mean for projects like PhantomJS?
Arguably the purpose of doing automated testing in a browser is to replicate and validate the end user experience. PhantomJS has been a good approximation of the end user experience, but no one will ever be browsing your website with PhantomJS.
It is also not a trivial task to construct tests that run reliably across multiple browsers. While PhantomJS is reasonably mature and battle-tested, there are always going to be some edge cases that you need to work around. Dealing with alerts is a good example of one of these edge cases, and so the decision to add PhantomJS as a test target should not be taken lightly.
But most significant is the fact that PhantomJS is not going to get much support from now on. One of the maintainers has stepped down, and there hasn’t been a new release in close to two years. Given how quickly web standards are evolving, along with browsers that have monthly release cycles, PhantomJS has slipped quite far behind the browsers your customers will actually be using.
Given PhantomJS is an unmaintained platform that no longer reflects the real end-user experience, and given that both Chrome and Firefox now support headless browsing natively, I would recommend not testing against PhantomJS. While PhantomJS was an excellent tool that filled a gap in the testing landscape a few years ago, today there are better options.
If you are interested in writing end-to-end tests against headless browsers, check out my project Iridium, which is a free and open source project on GitHub. The Iridium documentation talks about testing headless browser, and there is also a course on Udemy.