Puppeteer
In 2018, Google released the Puppeteer JavaScript library, which has drastically increased the ease with which end-to-end testing can be set up on a JavaScript-based project. Puppeteer is a headless version of the Chrome web browser, meaning that it has no GUI component. This is crucial, as it means we're testing our applications with a full Chrome browser, rather than a simulation.
Puppeteer can be controlled through jQuery-like syntax, where elements on an HTML page are selected by ID or class and interacted with. For example, the following code opens Google News, finds a .rdp59b
class, clicks on it, waits 3 seconds, and finally takes a screenshot:
(async() => { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('http://news.google.com'); const more = await page.$(".rdp59b"); more.click(); await page.waitFor(3000); await page.screenshot({path: 'news.png'}); await browser...