When comparing xvfb vs Puppeteer, the Slant community recommends Puppeteer for most people. In the question“What are the best headless browsers for testing?” Puppeteer is ranked 2nd while xvfb is ranked 8th.
Ranked in these QuestionsQuestion Ranking
Pros
Pro You can launch REAL browser using xvfb
Just test in real-world browser - xvfb makes it possible to launch them without the real screen.
Pro Works great with modern node.js features
Pro Runs a real browser
Unlike the other options here, this is a real browser, just without the GUI parts. This means the quality of the test is much higher, and lets you do things like save to PDF or images.
Pro Actively developed and promoted by Google
Pro Complete API for Chromium included
Chromium tests depend on the same API that Puppeteer gives you access to, so all the features are included
Cons
Con xvfb is no browser
Con Problem with ports
If you are running multiple instances on some browser and you use xvfb to run instances on agents on Bamboo or Jenkins you will potentially have a problem with using ports.
The first instance you are starting takes on a port on the agent and then the second instance that would be run doesn't have a port to go to.
You can partially solve the problem by dynamically assigning the next available port to the new instance that comes to be executed.
This only works if we assume that all the instances start in different time intervals, but what you cannot know is which instance is going to get a port first if they start at the same time, then the instances will crash, those that started at the same time.
Con Not good for Cross Browser Tests
Since it only tests via Chromium, it won't help you test inconsistencies between browsers like Edge or Safari. There are projects to get around this, but they aren't mature.